Commit 20b97ec8 authored by Junling Bu's avatar Junling Bu
Browse files

chore[litemall-wx]: 使用微信开发者工具的格式化代码

parent 822d5075
......@@ -3,13 +3,13 @@ var api = require('./config/api.js');
var user = require('./utils/user.js');
App({
onLaunch: function () {
onLaunch: function() {
const updateManager = wx.getUpdateManager();
wx.getUpdateManager().onUpdateReady(function () {
wx.getUpdateManager().onUpdateReady(function() {
wx.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success: function (res) {
success: function(res) {
if (res.confirm) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate()
......@@ -18,7 +18,7 @@ App({
})
})
},
onShow: function (options) {
onShow: function(options) {
user.checkLogin().then(res => {
this.globalData.hasLogin = true;
}).catch(() => {
......
/**app.wxss**/
.container {
box-sizing: border-box;
background-color: #f4f4f4;
font-family: PingFangSC-Light,helvetica,'Heiti SC';
font-family: PingFangSC-Light, helvetica, 'Heiti SC';
}
view,image,text,navigator{
view, image, text, navigator {
box-sizing: border-box;
padding:0;
margin:0;
padding: 0;
margin: 0;
}
view,text{
font-family: PingFangSC-Light,helvetica,'Heiti SC';
view, text {
font-family: PingFangSC-Light, helvetica, 'Heiti SC';
font-size: 29rpx;
color: #333;
}
// 以下是业务服务器API地址
// 本机开发时使用
var WxApiRoot = 'http://localhost:8080/wx/';
var WxApiRoot = 'http://localhost:8080/wx/';
// 局域网测试使用
// var WxApiRoot = 'http://192.168.0.101:8080/wx/';
// 云平台部署时使用
......
......@@ -10,26 +10,26 @@ Page({
code: '',
loginErrorCount: 0
},
onLoad: function (options) {
onLoad: function(options) {
// 页面初始化 options为页面跳转所带来的参数
// 页面渲染完成
},
onReady: function () {
onReady: function() {
},
onShow: function () {
onShow: function() {
// 页面显示
},
onHide: function () {
onHide: function() {
// 页面隐藏
},
onUnload: function () {
onUnload: function() {
// 页面关闭
},
accountLogin: function () {
accountLogin: function() {
var that = this;
if (this.data.password.length < 1 || this.data.username.length < 1) {
......@@ -51,24 +51,23 @@ Page({
header: {
'content-type': 'application/json'
},
success: function (res) {
if (res.data.errno == 0){
success: function(res) {
if (res.data.errno == 0) {
that.setData({
loginErrorCount: 0
});
app.globalData.hasLogin = true;
wx.setStorageSync('userInfo', res.data.data.userInfo);
wx.setStorage({
key:"token",
key: "token",
data: res.data.data.token,
success: function(){
success: function() {
wx.switchTab({
url: '/pages/ucenter/index/index'
});
}
});
}
else{
} else {
that.setData({
loginErrorCount: that.data.loginErrorCount + 1
});
......@@ -78,25 +77,25 @@ Page({
}
});
},
bindUsernameInput: function (e) {
bindUsernameInput: function(e) {
this.setData({
username: e.detail.value
});
},
bindPasswordInput: function (e) {
bindPasswordInput: function(e) {
this.setData({
password: e.detail.value
});
},
bindCodeInput: function (e) {
bindCodeInput: function(e) {
this.setData({
code: e.detail.value
});
},
clearInput: function (e) {
clearInput: function(e) {
switch (e.currentTarget.id) {
case 'clear-username':
this.setData({
......
......@@ -4,27 +4,27 @@ var user = require('../../../utils/user.js');
var app = getApp();
Page({
onLoad: function (options) {
onLoad: function(options) {
// 页面初始化 options为页面跳转所带来的参数
// 页面渲染完成
},
onReady: function () {
onReady: function() {
},
onShow: function () {
onShow: function() {
// 页面显示
},
onHide: function () {
onHide: function() {
// 页面隐藏
},
onUnload: function () {
onUnload: function() {
// 页面关闭
},
wxLogin: function (e) {
if (e.detail.userInfo == undefined){
wxLogin: function(e) {
if (e.detail.userInfo == undefined) {
app.globalData.hasLogin = false;
util.showErrorToast('微信登录失败');
return;
......@@ -45,7 +45,9 @@ Page({
});
},
accountLogin: function () {
wx.navigateTo({ url: "/pages/auth/accountLogin/accountLogin" });
accountLogin: function() {
wx.navigateTo({
url: "/pages/auth/accountLogin/accountLogin"
});
}
})
\ No newline at end of file
var api = require('../../../config/api.js');
var check = require('../../../utils/check.js');
......@@ -11,27 +10,27 @@ Page({
mobile: '',
code: ''
},
onLoad: function (options) {
onLoad: function(options) {
// 页面初始化 options为页面跳转所带来的参数
// 页面渲染完成
},
onReady: function () {
onReady: function() {
},
onShow: function () {
onShow: function() {
// 页面显示
},
onHide: function () {
onHide: function() {
// 页面隐藏
},
onUnload: function () {
onUnload: function() {
// 页面关闭
},
sendCode: function () {
sendCode: function() {
let that = this;
if (this.data.mobile.length == 0) {
......@@ -61,15 +60,14 @@ Page({
header: {
'content-type': 'application/json'
},
success: function (res) {
success: function(res) {
if (res.data.errno == 0) {
wx.showModal({
title: '发送成功',
content: '验证码已发送',
showCancel: false
});
}
else {
} else {
wx.showModal({
title: '错误信息',
content: res.data.errmsg,
......@@ -79,7 +77,7 @@ Page({
}
});
},
requestRegister: function (wxCode) {
requestRegister: function(wxCode) {
let that = this;
wx.request({
url: api.AuthRegister,
......@@ -94,21 +92,20 @@ Page({
header: {
'content-type': 'application/json'
},
success: function (res) {
success: function(res) {
if (res.data.errno == 0) {
app.globalData.hasLogin = true;
wx.setStorageSync('userInfo', res.data.data.userInfo);
wx.setStorage({
key: "token",
data: res.data.data.token,
success: function () {
success: function() {
wx.switchTab({
url: '/pages/ucenter/index/index'
});
}
});
}
else {
} else {
wx.showModal({
title: '错误信息',
content: res.data.errmsg,
......@@ -118,7 +115,7 @@ Page({
}
});
},
startRegister: function () {
startRegister: function() {
var that = this;
if (this.data.password.length < 6 || this.data.username.length < 6) {
......@@ -158,7 +155,7 @@ Page({
}
wx.login({
success: function (res) {
success: function(res) {
if (!res.code) {
wx.showModal({
title: '错误信息',
......@@ -171,37 +168,37 @@ Page({
}
});
},
bindUsernameInput: function (e) {
bindUsernameInput: function(e) {
this.setData({
username: e.detail.value
});
},
bindPasswordInput: function (e) {
bindPasswordInput: function(e) {
this.setData({
password: e.detail.value
});
},
bindConfirmPasswordInput: function (e) {
bindConfirmPasswordInput: function(e) {
this.setData({
confirmPassword: e.detail.value
});
},
bindMobileInput: function (e) {
bindMobileInput: function(e) {
this.setData({
mobile: e.detail.value
});
},
bindCodeInput: function (e) {
bindCodeInput: function(e) {
this.setData({
code: e.detail.value
});
},
clearInput: function (e) {
clearInput: function(e) {
switch (e.currentTarget.id) {
case 'clear-username':
this.setData({
......
......@@ -7,12 +7,12 @@
</view>
<view class="form-item">
<input class="password" value="{{password}}" password bindinput="bindPasswordInput" placeholder="密码"/>
<input class="password" value="{{password}}" password bindinput="bindPasswordInput" placeholder="密码" />
<image class="clear" id="clear-password" wx:if="{{ password.length > 0 }}" src="/static/images/clear_input.png" catchtap="clearInput"></image>
</view>
<view class="form-item">
<input class="password" value="{{confirmPassword}}" password bindinput="bindConfirmPasswordInput" placeholder="确认密码"/>
<input class="password" value="{{confirmPassword}}" password bindinput="bindConfirmPasswordInput" placeholder="确认密码" />
<image class="clear" id="clear-confirm-password" wx:if="{{ confirmPassword.length > 0 }}" src="/static/images/clear_input.png" catchtap="clearInput"></image>
</view>
......@@ -21,9 +21,9 @@
<image wx:if="{{ mobile.length > 0 }}" id="clear-mobile" class="clear" src="/static/images/clear_input.png" catchtap="clearInput"></image>
</view>
<view class="form-item-code" >
<view class="form-item-code">
<view class="form-item code-item">
<input class="code" value="{{code}}" bindinput="bindCodeInput" placeholder="验证码"/>
<input class="code" value="{{code}}" bindinput="bindCodeInput" placeholder="验证码" />
<image class="clear" id="clear-code" wx:if="{{ code.length > 0 }}" src="/static/images/clear_input.png" catchtap="clearInput"></image>
</view>
<view class="code-btn" bindtap="sendCode">获取验证码</view>
......
.form-box{
.form-box {
width: 100%;
height: auto;
overflow: hidden;
......@@ -7,14 +7,14 @@
background: #fff;
}
.form-item{
.form-item {
position: relative;
background: #fff;
height: 96rpx;
border-bottom: 1px solid #d9d9d9;
}
.form-item .username, .form-item .password, .form-item .mobile, .form-item .code{
.form-item .username, .form-item .password, .form-item .mobile, .form-item .code {
position: absolute;
top: 26rpx;
left: 0;
......@@ -26,19 +26,19 @@
font-size: 30rpx;
}
.form-item-code{
margin-top:32rpx;
.form-item-code {
margin-top: 32rpx;
height: auto;
overflow: hidden;
width: 100%;
}
.form-item-code .form-item{
.form-item-code .form-item {
float: left;
width: 350rpx;
}
.form-item-code .code-btn{
.form-item-code .code-btn {
float: right;
padding: 20rpx 40rpx;
border: 1px solid #d9d9d9;
......@@ -47,7 +47,7 @@
background: green;
}
.form-item .clear{
.form-item .clear {
position: absolute;
top: 26rpx;
right: 18rpx;
......@@ -58,7 +58,7 @@
width: 44rpx;
}
.register-btn{
.register-btn {
margin: 60rpx 0 40rpx 0;
height: 96rpx;
line-height: 96rpx;
......
......@@ -9,28 +9,28 @@ Page({
password: '',
confirmPassword: ''
},
onLoad: function (options) {
onLoad: function(options) {
// 页面初始化 options为页面跳转所带来的参数
// 页面渲染完成
},
onReady: function () {
onReady: function() {
},
onShow: function () {
onShow: function() {
// 页面显示
},
onHide: function () {
onHide: function() {
// 页面隐藏
},
onUnload: function () {
onUnload: function() {
// 页面关闭
},
sendCode: function () {
sendCode: function() {
let that = this;
wx.request({
url: api.AuthRegisterCaptcha,
......@@ -41,15 +41,14 @@ Page({
header: {
'content-type': 'application/json'
},
success: function (res) {
success: function(res) {
if (res.data.errno == 0) {
wx.showModal({
title: '发送成功',
content: '验证码已发送',
showCancel: false
});
}
else {
} else {
wx.showModal({
title: '错误信息',
content: res.data.errmsg,
......@@ -59,7 +58,7 @@ Page({
}
});
},
startReset: function(){
startReset: function() {
var that = this;
if (this.data.mobile.length == 0 || this.data.code.length == 0) {
......@@ -109,11 +108,10 @@ Page({
header: {
'content-type': 'application/json'
},
success: function (res) {
success: function(res) {
if (res.data.errno == 0) {
wx.navigateBack();
}
else{
} else {
wx.showModal({
title: '密码重置失败',
content: res.data.errmsg,
......@@ -123,32 +121,32 @@ Page({
}
});
},
bindPasswordInput: function (e) {
bindPasswordInput: function(e) {
this.setData({
password: e.detail.value
});
},
bindConfirmPasswordInput: function (e) {
bindConfirmPasswordInput: function(e) {
this.setData({
confirmPassword: e.detail.value
});
},
bindMobileInput: function (e) {
bindMobileInput: function(e) {
this.setData({
mobile: e.detail.value
});
},
bindCodeInput: function(e){
bindCodeInput: function(e) {
this.setData({
code: e.detail.value
});
},
clearInput: function(e){
switch (e.currentTarget.id){
clearInput: function(e) {
switch (e.currentTarget.id) {
case 'clear-password':
this.setData({
password: ''
......
.form-box{
.form-box {
width: 100%;
height: auto;
overflow: hidden;
......@@ -7,14 +7,14 @@
background: #fff;
}
.form-item{
.form-item {
position: relative;
background: #fff;
height: 96rpx;
border-bottom: 1px solid #d9d9d9;
}
.form-item .mobile, .form-item .password, .form-item .code{
.form-item .mobile, .form-item .password, .form-item .code {
position: absolute;
top: 26rpx;
left: 0;
......@@ -26,26 +26,26 @@
font-size: 30rpx;
}
.form-item-code{
margin-top:32rpx;
.form-item-code {
margin-top: 32rpx;
height: auto;
overflow: hidden;
width: 100%;
}
.form-item-code .form-item{
.form-item-code .form-item {
float: left;
width: 350rpx;
}
.form-item-code .code-btn{
.form-item-code .code-btn {
float: right;
padding: 20rpx 40rpx;
border: 1px solid #d9d9d9;
border-radius: 10rpx;
}
.form-item .clear{
.form-item .clear {
position: absolute;
top: 26rpx;
right: 18rpx;
......@@ -56,7 +56,7 @@
width: 44rpx;
}
.reset-btn{
.reset-btn {
margin: 60rpx 0 40rpx 0;
height: 96rpx;
line-height: 96rpx;
......
......@@ -8,16 +8,19 @@ Page({
size: 10,
totalPages: 1
},
onLoad: function (options) {
onLoad: function(options) {
// 页面初始化 options为页面跳转所带来的参数
this.getBrandList();
},
getBrandList: function () {
getBrandList: function() {
wx.showLoading({
title: '加载中...',
});
let that = this;
util.request(api.BrandList, { page: that.data.page, size: that.data.size }).then(function (res) {
util.request(api.BrandList, {
page: that.data.page,
size: that.data.size
}).then(function(res) {
if (res.errno === 0) {
that.setData({
brandList: that.data.brandList.concat(res.data.brandList),
......@@ -27,7 +30,7 @@ Page({
wx.hideLoading();
});
},
onReachBottom (){
onReachBottom() {
if (this.data.totalPages > this.data.page) {
this.setData({
page: this.data.page + 1
......@@ -38,18 +41,18 @@ Page({
this.getBrandList();
},
onReady: function () {
onReady: function() {
},
onShow: function () {
onShow: function() {
// 页面显示
},
onHide: function () {
onHide: function() {
// 页面隐藏
},
onUnload: function () {
onUnload: function() {
// 页面关闭
}
......
<view class="container">
<view class="brand-list" >
<view class="brand-list">
<navigator url="../brandDetail/brandDetail?id={{item.id}}" class="item" wx:for="{{brandList}}" wx:key="id">
<view class="img-bg">
<image src="{{item.picUrl}}" background-size="cover"></image>
</view>
<view class="txt-box">
<view class="line">
<text class="name" >{{item.name}}</text>
<text class="name">{{item.name}}</text>
<text class="s">|</text>
<text class="price">{{item.floorPrice}}元起</text>
</view>
</view>
</navigator >
</navigator>
</view>
</view>
\ No newline at end of file
.brand-list .item{
.brand-list .item {
display: block;
width: 750rpx;
height: 416rpx;
......@@ -6,32 +6,32 @@
margin-bottom: 4rpx;
}
.brand-list .item .img-bg{
.brand-list .item .img-bg {
position: absolute;
left:0;
top:0;
left: 0;
top: 0;
z-index: 0;
width: 750rpx;
height: 417rpx;
overflow: hidden;
}
.brand-list .item .img-bg image{
.brand-list .item .img-bg image {
width: 750rpx;
height: 416rpx;
}
.brand-list .item .txt-box{
.brand-list .item .txt-box {
position: absolute;
left:0;
top:0;
left: 0;
top: 0;
display: table;
z-index: 0;
width: 750rpx;
height: 417rpx;
}
.brand-list .item .line{
.brand-list .item .line {
display: table-cell;
vertical-align: middle;
text-align: center;
......@@ -39,14 +39,14 @@
line-height: 63rpx;
}
.brand-list .item .line text{
.brand-list .item .line text {
font-size: 35rpx;
font-weight: 700;
text-shadow: 1rpx 1rpx rgba(0,0,0,.32);
text-shadow: 1rpx 1rpx rgba(0, 0, 0, 0.32);
color: #fff;
}
.brand-list .item .line .s{
.brand-list .item .line .s {
padding: 0 10rpx;
font-size: 40rpx;
}
......@@ -12,7 +12,7 @@ Page({
page: 1,
size: 100
},
onLoad: function (options) {
onLoad: function(options) {
// 页面初始化 options为页面跳转所带来的参数
var that = this;
that.setData({
......@@ -20,9 +20,11 @@ Page({
});
this.getBrand();
},
getBrand: function () {
getBrand: function() {
let that = this;
util.request(api.BrandDetail, { id: that.data.id }).then(function (res) {
util.request(api.BrandDetail, {
id: that.data.id
}).then(function(res) {
if (res.errno === 0) {
that.setData({
brand: res.data.brand
......@@ -35,8 +37,12 @@ Page({
getGoodsList() {
var that = this;
util.request(api.GoodsList, { brandId: that.data.id, page: that.data.page, size: that.data.size})
.then(function (res) {
util.request(api.GoodsList, {
brandId: that.data.id,
page: that.data.page,
size: that.data.size
})
.then(function(res) {
if (res.errno === 0) {
that.setData({
goodsList: res.data.goodsList
......@@ -44,19 +50,19 @@ Page({
}
});
},
onReady: function () {
onReady: function() {
// 页面渲染完成
},
onShow: function () {
onShow: function() {
// 页面显示
},
onHide: function () {
onHide: function() {
// 页面隐藏
},
onUnload: function () {
onUnload: function() {
// 页面关闭
}
......
page{
page {
background: #f4f4f4;
}
.brand-info .name{
.brand-info .name {
width: 100%;
height: 290rpx;
position: relative;
}
.brand-info .img{
.brand-info .img {
position: absolute;
top:0;
left:0;
top: 0;
left: 0;
width: 100%;
height: 290rpx;
}
.brand-info .info-box{
.brand-info .info-box {
position: absolute;
top:0;
left:0;
top: 0;
left: 0;
width: 100%;
height: 290rpx;
text-align: center;
......@@ -27,18 +28,18 @@ page{
align-items: center;
}
.brand-info .info{
.brand-info .info {
display: block;
}
.brand-info .txt{
.brand-info .txt {
display: block;
height: 37.5rpx;
font-size: 37.5rpx;
color: #fff;
}
.brand-info .line{
.brand-info .line {
margin: 0 auto;
margin-top: 16rpx;
display: block;
......@@ -47,7 +48,7 @@ page{
background: #fff;
}
.brand-info .desc{
.brand-info .desc {
background: #fff;
width: 100%;
height: auto;
......@@ -59,7 +60,7 @@ page{
text-align: center;
}
.cate-item .b{
.cate-item .b {
width: 750rpx;
height: auto;
overflow: hidden;
......@@ -67,7 +68,7 @@ page{
margin-top: 20rpx;
}
.cate-item .b .item{
.cate-item .b .item {
float: left;
background: #fff;
width: 375rpx;
......@@ -78,17 +79,17 @@ page{
text-align: center;
}
.cate-item .b .item-b{
.cate-item .b .item-b {
border-right: 1rpx solid #f4f4f4;
}
.cate-item .item .img{
.cate-item .item .img {
margin-top: 10rpx;
width: 302rpx;
height: 302rpx;
}
.cate-item .item .name{
.cate-item .item .name {
display: block;
width: 365.625rpx;
height: 35rpx;
......@@ -100,7 +101,7 @@ page{
color: #333;
}
.cate-item .item .price{
.cate-item .item .price {
display: block;
width: 365.625rpx;
height: 30rpx;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment