作者 乔蒙蒙

对接接口

@@ -103,6 +103,7 @@ App({ @@ -103,6 +103,7 @@ App({
103 return dateObj; 103 return dateObj;
104 }, 104 },
105 globalData: { 105 globalData: {
106 - userInfo: null 106 + userInfo: null,
  107 + imgUrl: 'http://qiniu.conyou-zj.com/'
107 } 108 }
108 }) 109 })
1 { 1 {
2 - "pages": [  
3 - "pages/kaishi/kaishi",  
4 - "pages/index/index",  
5 - "pages/merchant/login/login",  
6 - "pages/merchant/account/account",  
7 - "pages/merchant/tixian/tixian",  
8 - "pages/merchant/tixian2/tixian2",  
9 - "pages/merchant/account_info/account_info",  
10 - "pages/merchant/account_manage/account_manage",  
11 - "pages/merchant/merchant_center/merchant_center",  
12 - "pages/merchant/merchant_register/merchant_register",  
13 - "pages/merchant/merchant_addgoods/merchant_addgoods",  
14 - "pages/merchant/add_combo/add_combo",  
15 - "pages/merchant/add_kazuo/add_kazuo",  
16 - "pages/merchant/one_add/one_add",  
17 - "pages/merchant/my_order/my_order",  
18 - "pages/merchant/pay_detail/pay_detail",  
19 - "pages/merchant/goodslist/goodslist",  
20 - "pages/merchant/merchant_index/merchant_index",  
21 - "pages/merchant/merchant_imgs/merchant_imgs",  
22 - "pages/my/my",  
23 - "pages/client_pay/client_pay",  
24 - "pages/apply_yes/apply_yes",  
25 - "pages/my_account/my_account",  
26 - "pages/choose_time/choose_time",  
27 - "pages/true_approve/true_approve",  
28 - "pages/location/location",  
29 - "pages/form/form",  
30 - "pages/plaza/plaza",  
31 - "pages/more_imgs/more_imgs",  
32 - "pages/facility/facility",  
33 - "pages/tuangou/tuanguo",  
34 - "pages/taocan_detail/taocan_detail",  
35 - "pages/my_order/my_order",  
36 - "pages/my_zhudui/my_zhudui",  
37 - "pages/evaluate/evaluate",  
38 - "pages/bar_detail/bar_detail",  
39 - "pages/my_class/my_class",  
40 - "pages/img_txt/img_txt",  
41 - "pages/start/start",  
42 - "pages/zudui_pay/zudui_pay",  
43 - "pages/share/share",  
44 - "pages/merchant/register/register",  
45 - "pages/merchant/register_yes/register_yes",  
46 - "pages/merchant/scan/scan",  
47 - "pages/merchant/merchant_registerinfo/merchant_registerinfo",  
48 - "pages/merchant/account_list/account_list",  
49 - "pages/merchant/edit_account/edit_account",  
50 - "pages/merchant/merchant_share/merchant_share",  
51 - "pages/merchant/merchant_explain/merchant_explain",  
52 - "pages/merchant/merchant_activity/merchant_activity",  
53 - "pages/merchant/merchant_info/merchant_info",  
54 - "pages/merchant/user_agree/user_agree",  
55 - "pages/my_zhuduidetail/my_zhuduidetail",  
56 - "pages/my_orderdetai/my_orderdetail",  
57 - "pages/login/login",  
58 - "pages/my_ordersuccess/my_ordersuccess"  
59 - ],  
60 - "window": {  
61 - "backgroundTextStyle": "light",  
62 - "navigationBarBackgroundColor": "#031A2F",  
63 - "navigationBarTitleText": "友从",  
64 - "navigationBarTextStyle": "white"  
65 - },  
66 - "tabBar": {  
67 - "color": "#CCCCCC",  
68 - "selectedColor": "#fff",  
69 - "backgroundColor": "#011125",  
70 - "list": [  
71 - {  
72 - "pagePath": "pages/index/index",  
73 - "text": "首页",  
74 - "iconPath": "imgs/icon2.png",  
75 - "selectedIconPath": "imgs/icon22.png"  
76 - },  
77 - {  
78 - "pagePath": "pages/plaza/plaza",  
79 - "text": "广场",  
80 - "iconPath": "imgs/icon1.png",  
81 - "selectedIconPath": "imgs/icon11.png"  
82 - },  
83 - {  
84 - "pagePath": "pages/my/my",  
85 - "text": "我的",  
86 - "iconPath": "imgs/icon3.png",  
87 - "selectedIconPath": "imgs/icon33.png"  
88 - }  
89 - ]  
90 - } 2 + "pages": [
  3 + "pages/kaishi/kaishi",
  4 + "pages/index/index",
  5 + "pages/merchant/login/login",
  6 + "pages/merchant/account/account",
  7 + "pages/merchant/tixian/tixian",
  8 + "pages/merchant/tixian2/tixian2",
  9 + "pages/merchant/account_info/account_info",
  10 + "pages/merchant/account_manage/account_manage",
  11 + "pages/merchant/merchant_center/merchant_center",
  12 + "pages/merchant/merchant_register/merchant_register",
  13 + "pages/merchant/merchant_addgoods/merchant_addgoods",
  14 + "pages/merchant/add_combo/add_combo",
  15 + "pages/merchant/add_kazuo/add_kazuo",
  16 + "pages/merchant/one_add/one_add",
  17 + "pages/merchant/my_order/my_order",
  18 + "pages/merchant/pay_detail/pay_detail",
  19 + "pages/merchant/goodslist/goodslist",
  20 + "pages/merchant/merchant_index/merchant_index",
  21 + "pages/merchant/merchant_imgs/merchant_imgs",
  22 + "pages/my/my",
  23 + "pages/client_pay/client_pay",
  24 + "pages/apply_yes/apply_yes",
  25 + "pages/my_account/my_account",
  26 + "pages/choose_time/choose_time",
  27 + "pages/true_approve/true_approve",
  28 + "pages/location/location",
  29 + "pages/form/form",
  30 + "pages/plaza/plaza",
  31 + "pages/more_imgs/more_imgs",
  32 + "pages/facility/facility",
  33 + "pages/tuangou/tuanguo",
  34 + "pages/taocan_detail/taocan_detail",
  35 + "pages/my_order/my_order",
  36 + "pages/my_zhudui/my_zhudui",
  37 + "pages/evaluate/evaluate",
  38 + "pages/bar_detail/bar_detail",
  39 + "pages/my_class/my_class",
  40 + "pages/img_txt/img_txt",
  41 + "pages/start/start",
  42 + "pages/zudui_pay/zudui_pay",
  43 + "pages/share/share",
  44 + "pages/merchant/register/register",
  45 + "pages/merchant/register_yes/register_yes",
  46 + "pages/merchant/scan/scan",
  47 + "pages/merchant/merchant_registerinfo/merchant_registerinfo",
  48 + "pages/merchant/account_list/account_list",
  49 + "pages/merchant/edit_account/edit_account",
  50 + "pages/merchant/merchant_share/merchant_share",
  51 + "pages/merchant/merchant_explain/merchant_explain",
  52 + "pages/merchant/merchant_activity/merchant_activity",
  53 + "pages/merchant/merchant_info/merchant_info",
  54 + "pages/merchant/user_agree/user_agree",
  55 + "pages/my_zhuduidetail/my_zhuduidetail",
  56 + "pages/my_orderdetai/my_orderdetail",
  57 + "pages/login/login",
  58 + "pages/my_ordersuccess/my_ordersuccess"
  59 + ],
  60 + "window": {
  61 + "backgroundTextStyle": "light",
  62 + "navigationBarBackgroundColor": "#031A2F",
  63 + "navigationBarTitleText": "友从",
  64 + "navigationBarTextStyle": "white"
  65 + },
  66 + "tabBar": {
  67 + "color": "#CCCCCC",
  68 + "selectedColor": "#fff",
  69 + "backgroundColor": "#011125",
  70 + "list": [
  71 + {
  72 + "pagePath": "pages/index/index",
  73 + "text": "首页",
  74 + "iconPath": "imgs/icon2.png",
  75 + "selectedIconPath": "imgs/icon22.png"
  76 + },
  77 + {
  78 + "pagePath": "pages/plaza/plaza",
  79 + "text": "广场",
  80 + "iconPath": "imgs/icon1.png",
  81 + "selectedIconPath": "imgs/icon11.png"
  82 + },
  83 + {
  84 + "pagePath": "pages/my/my",
  85 + "text": "我的",
  86 + "iconPath": "imgs/icon3.png",
  87 + "selectedIconPath": "imgs/icon33.png"
  88 + }
  89 + ]
  90 + }
91 } 91 }
1 //index.js 1 //index.js
  2 +const app = getApp();
2 Page({ 3 Page({
3 4
4 - /**  
5 - * 页面的初始数据  
6 - */  
7 - data: {  
8 - rankstate:0//0综合,1距离,2销量,3筛选  
9 - },  
10 - setrankstate(e){  
11 -  
12 - this.setData({  
13 - rankstate: e.currentTarget.dataset.rankstate  
14 - })  
15 -  
16 - },  
17 - /**  
18 - * 生命周期函数--监听页面加载  
19 - */  
20 - onLoad: function (options) {  
21 -  
22 - },  
23 -  
24 - /**  
25 - * 生命周期函数--监听页面初次渲染完成  
26 - */  
27 - onReady: function () {  
28 -  
29 - },  
30 -  
31 - /**  
32 - * 生命周期函数--监听页面显示  
33 - */  
34 - onShow: function () {  
35 -  
36 - },  
37 -  
38 - /**  
39 - * 生命周期函数--监听页面隐藏  
40 - */  
41 - onHide: function () {  
42 -  
43 - },  
44 -  
45 - /**  
46 - * 生命周期函数--监听页面卸载  
47 - */  
48 - onUnload: function () {  
49 -  
50 - },  
51 -  
52 - /**  
53 - * 页面相关事件处理函数--监听用户下拉动作  
54 - */  
55 - onPullDownRefresh: function () {  
56 -  
57 - },  
58 -  
59 - /**  
60 - * 页面上拉触底事件的处理函数  
61 - */  
62 - onReachBottom: function () {  
63 -  
64 - },  
65 -  
66 - /**  
67 - * 用户点击右上角分享  
68 - */  
69 - onShareAppMessage: function () {  
70 -  
71 - }  
72 -}) 5 + /**
  6 + * 页面的初始数据
  7 + */
  8 + data: {
  9 + imgUrl: app.globalData.imgUrl,
  10 + rankstate: 0, //0综合,1距离,2销量,3筛选
  11 + },
  12 + setrankstate(e) {
  13 +
  14 + this.setData({
  15 + rankstate: e.currentTarget.dataset.rankstate
  16 + })
  17 +
  18 + },
  19 + /**
  20 + * 生命周期函数--监听页面加载
  21 + */
  22 + onLoad: function(options) {
  23 +
  24 + },
  25 +
  26 + /**
  27 + * 生命周期函数--监听页面初次渲染完成
  28 + */
  29 + onReady: function() {
  30 +
  31 + },
  32 +
  33 + /**
  34 + * 生命周期函数--监听页面显示
  35 + */
  36 + onShow: function() {
  37 +
  38 + },
  39 +
  40 + /**
  41 + * 生命周期函数--监听页面隐藏
  42 + */
  43 + onHide: function() {
  44 +
  45 + },
  46 +
  47 + /**
  48 + * 生命周期函数--监听页面卸载
  49 + */
  50 + onUnload: function() {
  51 +
  52 + },
  53 +
  54 + /**
  55 + * 页面相关事件处理函数--监听用户下拉动作
  56 + */
  57 + onPullDownRefresh: function() {
  58 +
  59 + },
  60 +
  61 + /**
  62 + * 页面上拉触底事件的处理函数
  63 + */
  64 + onReachBottom: function() {
  65 +
  66 + },
  67 +
  68 + /**
  69 + * 用户点击右上角分享
  70 + */
  71 + onShareAppMessage: function() {
  72 +
  73 + }
  74 +})
1 <!--index.wxml--> 1 <!--index.wxml-->
2 <navigator class='index_img' hover-class='navigator_hover' url='/pages/tuangou/tuanguo'> 2 <navigator class='index_img' hover-class='navigator_hover' url='/pages/tuangou/tuanguo'>
3 - <image src='../../../imgs/dianoufengmian@3x.png'></image>  
4 -</navigator > 3 + <image src='{{imgUrl}}dianoufengmian@3x.png'></image>
  4 +</navigator>
5 <view class='index_class'> 5 <view class='index_class'>
6 - <navigator class='index_classcell' hover-class='navigator_hover' url='/pages/tuangou/tuanguo'>  
7 - <view>品质团购</view>  
8 - <view class='index_classcellsub'>Quality group purchase</view>  
9 - </navigator>  
10 - <navigator class='index_classcell index_classcell1' hover-class='navigator_hover' url='/pages/tuangou/tuanguo'>  
11 - <view>热门团购</view>  
12 - <view class='index_classcellsub'>Hot group buying</view>  
13 - </navigator>  
14 - <navigator class='index_classcell index_classcell2' hover-class='navigator_hover' url='/pages/tuangou/tuanguo'>  
15 - <view>限量抢购</view>  
16 - <view class='index_classcellsub'>Limited purchase</view>  
17 - </navigator> 6 + <navigator class='index_classcell' hover-class='navigator_hover' url='/pages/tuangou/tuanguo'>
  7 + <view>品质团购</view>
  8 + <view class='index_classcellsub'>Quality group purchase</view>
  9 + </navigator>
  10 + <navigator class='index_classcell index_classcell1' hover-class='navigator_hover' url='/pages/tuangou/tuanguo'>
  11 + <view>热门团购</view>
  12 + <view class='index_classcellsub'>Hot group buying</view>
  13 + </navigator>
  14 + <navigator class='index_classcell index_classcell2' hover-class='navigator_hover' url='/pages/tuangou/tuanguo'>
  15 + <view>限量抢购</view>
  16 + <view class='index_classcellsub'>Limited purchase</view>
  17 + </navigator>
18 </view> 18 </view>
19 <view class='index_title'>热门酒吧</view> 19 <view class='index_title'>热门酒吧</view>
20 <view class='plaza_nav'> 20 <view class='plaza_nav'>
21 - <view class="plaza_navitem {{rankstate==0?'navitem_active':''}}" data-rankstate='0' bindtap='setrankstate' >  
22 - <view class=' plaza_navitemimg iconfont icon-fenlei-'></view>  
23 - <view>综合排序</view>  
24 - </view>  
25 - <view class="plaza_navitem {{rankstate==1?'navitem_active':''}}" data-rankstate='1' bindtap='setrankstate'>  
26 - <view class='plaza_navitemimg iconfont icon-qunfengdingwei'></view>  
27 - <view>距离最近</view>  
28 - </view>  
29 - <view class="plaza_navitem {{rankstate==2?'navitem_active':''}}" data-rankstate='2' bindtap='setrankstate'>  
30 - <view class='plaza_navitemimg iconfont icon-paixing'></view>  
31 - <view>销量最好</view>  
32 - </view>  
33 - <view class="plaza_navitem {{rankstate==3?'navitem_active':''}}" data-rankstate='3' bindtap='setrankstate'>  
34 - <view class='plaza_navitemimg iconfont icon-sousuo'></view>  
35 - <view>筛选</view>  
36 - </view> 21 + <view class="plaza_navitem {{rankstate==0?'navitem_active':''}}" data-rankstate='0' bindtap='setrankstate'>
  22 + <view class=' plaza_navitemimg iconfont icon-fenlei-'></view>
  23 + <view>综合排序</view>
  24 + </view>
  25 + <view class="plaza_navitem {{rankstate==1?'navitem_active':''}}" data-rankstate='1' bindtap='setrankstate'>
  26 + <view class='plaza_navitemimg iconfont icon-qunfengdingwei'></view>
  27 + <view>距离最近</view>
  28 + </view>
  29 + <view class="plaza_navitem {{rankstate==2?'navitem_active':''}}" data-rankstate='2' bindtap='setrankstate'>
  30 + <view class='plaza_navitemimg iconfont icon-paixing'></view>
  31 + <view>销量最好</view>
  32 + </view>
  33 + <view class="plaza_navitem {{rankstate==3?'navitem_active':''}}" data-rankstate='3' bindtap='setrankstate'>
  34 + <view class='plaza_navitemimg iconfont icon-sousuo'></view>
  35 + <view>筛选</view>
  36 + </view>
37 </view> 37 </view>
38 <view class='formbox plazabox'> 38 <view class='formbox plazabox'>
39 - <navigator class='order_img plaza_img' hover-class='navigator_hover' url='/pages/bar_detail/bar_detail'>  
40 - <view class='order_imgtxt'>  
41 - <view class='order_imgtxttitle'>夜色酒吧</view>  
42 - <view class='order_imgtxtsubtitle'>[主题酒吧]</view>  
43 - </view>  
44 - <view class='order_imgtime'>月售120单</view>  
45 - <image src='../../../imgs/dianoufengmian@3x.png'></image>  
46 - </navigator>  
47 - <view class='formitem'>  
48 - <view class='formitem_rigth form_nimi'>  
49 - <view class='formitem_rigth_jian'> <text class='jian_txt'> 减</text>  
50 - </view>  
51 - 满1000减300 满1500减500 满2000减800  
52 - </view>  
53 - </view> 39 + <navigator class='order_img plaza_img' hover-class='navigator_hover' url='/pages/bar_detail/bar_detail'>
  40 + <view class='order_imgtxt'>
  41 + <view class='order_imgtxttitle'>夜色酒吧</view>
  42 + <view class='order_imgtxtsubtitle'>[主题酒吧]</view>
  43 + </view>
  44 + <view class='order_imgtime'>月售120单</view>
  45 + <image src='{{imgUrl}}dianoufengmian@3x.png'></image>
  46 + </navigator>
  47 + <view class='formitem'>
  48 + <view class='formitem_rigth form_nimi'>
  49 + <view class='formitem_rigth_jian'>
  50 + <text class='jian_txt'> 减</text>
  51 + </view>
  52 + 满1000减300 满1500减500 满2000减800
  53 + </view>
  54 + </view>
54 </view> 55 </view>
@@ -7,9 +7,9 @@ Page({ @@ -7,9 +7,9 @@ Page({
7 */ 7 */
8 data: { 8 data: {
9 imgUrls: [ 9 imgUrls: [
10 - '../../imgs/lunbo1@3x.png',  
11 - '../../imgs/lunbo2@3x.png',  
12 - '../../imgs/lunbo3@3x.png' 10 + app.globalData.imgUrl + 'lunbo1@3x.png',
  11 + app.globalData.imgUrl + 'lunbo2@3x.png',
  12 + app.globalData.imgUrl + 'lunbo3@3x.png'
13 ], 13 ],
14 indexs: 0, 14 indexs: 0,
15 color: '#cccccc', 15 color: '#cccccc',
@@ -17,7 +17,8 @@ Page({ @@ -17,7 +17,8 @@ Page({
17 autoplay: true, 17 autoplay: true,
18 activecolor: '#ffffff', 18 activecolor: '#ffffff',
19 interval: 5000, 19 interval: 5000,
20 - duration: 1000 20 + duration: 1000,
  21 + imgUrl: app.globalData.imgUrl
21 }, 22 },
22 23
23 start(e) { 24 start(e) {
@@ -32,9 +33,9 @@ Page({ @@ -32,9 +33,9 @@ Page({
32 code: s.code 33 code: s.code
33 } 34 }
34 app.post(url, param).then((res) => { 35 app.post(url, param).then((res) => {
35 - console.log(res);  
36 - console.log(e);  
37 - that.login(res.data.openid, res.data.session_key, e.detail.encryptedData, e.detail.iv, e.detail.rawData, e.detail.signature); 36 + // console.log(res);
  37 + // console.log(e);
  38 + that.login(res.data.openid, res.data.session_key, e.detail.encryptedData, e.detail.iv);
38 }).catch((errMsg) => { 39 }).catch((errMsg) => {
39 console.log(errMsg); 40 console.log(errMsg);
40 }) 41 })
@@ -42,47 +43,67 @@ Page({ @@ -42,47 +43,67 @@ Page({
42 } 43 }
43 }); 44 });
44 }, 45 },
45 - login(openid, session_key, encrypted_data, iv,r,s) { 46 + login(openid, session_key, encrypted_data, iv) {
46 let that = this; 47 let that = this;
47 - let param = {  
48 - openid: openid,  
49 - session_key: session_key,  
50 - encrypted_data: encrypted_data,  
51 - iv: iv,  
52 - rawData: r,  
53 - signature: s  
54 - }  
55 - let url = 'wxapp/public/login';  
56 - // wx.navigateTo({  
57 - // url: '/pages/login/login',  
58 - // success: function (res) { },  
59 - // fail: function (res) { },  
60 - // complete: function (res) { },  
61 - // })  
62 - app.post(url, param).then((res) => {  
63 - console.log(res)  
64 - wx.setStorageSync('token', res.data.token);  
65 - let u = "wxapp/public/isMobile";  
66 - let header = {  
67 - "XX-Token": res.data.token  
68 - }  
69 - let data = {  
70 - type: 1 48 + wx.checkSession({
  49 + success: function () {
  50 + console.log('未过期');
  51 + //session_key 未过期,并且在本生命周期一直有效
  52 + let param = {
  53 + openid: openid,
  54 + session_key: session_key,
  55 + encrypted_data: encrypted_data,
  56 + iv: iv,
  57 + }
  58 + let url = 'wxapp/public/login';
  59 +
  60 + app.post(url, param).then((res) => {
  61 + // console.log(res)
  62 + wx.setStorageSync('token', res.data.token);
  63 + let u = "wxapp/public/isMobile";
  64 + let header = {
  65 + "XX-Token": res.data.token
  66 + }
  67 + let data = {
  68 + type: 1
  69 + }
  70 + app.post(u, data, header).then((r) => {
  71 + console.log(r);
  72 + if (r.data.is_mobile == 2) {
  73 + wx.redirectTo({
  74 + url: '/pages/login/login',
  75 + success: function (res) { },
  76 + fail: function (res) { },
  77 + complete: function (res) { },
  78 + })
  79 + } else if (r.data.is_mobile == 1) {
  80 + wx.redirectTo({
  81 + url: '/pages/index/index',
  82 + success: function (res) { },
  83 + fail: function (res) { },
  84 + complete: function (res) { },
  85 + })
  86 + }
  87 + }).catch((err) => {
  88 +
  89 + })
  90 + // wx.navigateTo({
  91 + // url: '/pages/login/login',
  92 + // success: function (res) { },
  93 + // fail: function (res) { },
  94 + // complete: function (res) { },
  95 + // })
  96 + }).catch((errMsg) => {
  97 + console.log(errMsg);
  98 + })
  99 + },
  100 + fail: function () {
  101 + console.log('session_key 已经失效');
  102 + // session_key 已经失效,需要重新执行登录流程
  103 + that.start() //重新登录
71 } 104 }
72 - app.post(u, data, header).then((r) => {  
73 - console.log(r)  
74 - }).catch((err) => {  
75 -  
76 - })  
77 - // wx.navigateTo({  
78 - // url: '/pages/login/login',  
79 - // success: function (res) { },  
80 - // fail: function (res) { },  
81 - // complete: function (res) { },  
82 - // })  
83 - }).catch((errMsg) => {  
84 - console.log(errMsg);  
85 }) 105 })
  106 +
86 }, 107 },
87 changeindexs(e) { 108 changeindexs(e) {
88 this.setData({ 109 this.setData({
@@ -8,14 +8,14 @@ @@ -8,14 +8,14 @@
8 </block> 8 </block>
9 <swiper-item> 9 <swiper-item>
10 <view class='start_main'> 10 <view class='start_main'>
11 - <image src='../../imgs/yonghushouyedenglubiejing@3x.png'></image> 11 + <image src='{{imgUrl}}yonghushouyedenglubiejing@3x.png'></image>
12 <view class='head_txt'> 12 <view class='head_txt'>
13 <view class='head_title'>从友</view> 13 <view class='head_title'>从友</view>
14 <view>From·Friends</view> 14 <view>From·Friends</view>
15 <view class='head_subtitle'>让娱乐更简单</view> 15 <view class='head_subtitle'>让娱乐更简单</view>
16 </view> 16 </view>
17 <view class='logo'> 17 <view class='logo'>
18 - <image src='../../imgs/qdongtupian@3x.png'></image> 18 + <image src='{{imgUrl}}qdongtupian@3x.png'></image>
19 </view> 19 </view>
20 </view> 20 </view>
21 <view class='start_btnbox'> 21 <view class='start_btnbox'>
1 // pages/login/login.js 1 // pages/login/login.js
  2 +const app = getApp();
2 Page({ 3 Page({
3 4
4 - /**  
5 - * 页面的初始数据  
6 - */  
7 - data: {  
8 - timer: '', //定时器名字  
9 - codetxt:'输入验证码',  
10 - downsec: '60', //倒计时初始值  
11 - },  
12 - //倒计时  
13 - downsec() {  
14 - let that=this;  
15 - let downsec = that.data.downsec;  
16 - if (downsec == '60')  
17 - that.setData({  
18 - timer: setInterval(function () { //这里把setInterval赋值给变量名为timer的变量  
19 - //每隔一秒countDownNum就减一,实现同步  
20 - downsec--;  
21 - //然后把countDownNum存进data,好让用户知道时间在倒计着  
22 - that.setData({  
23 - downsec: downsec,  
24 - codetxt: downsec + 's'  
25 - })  
26 - //在倒计时还未到0时,这中间可以做其他的事情,按项目需求来  
27 - if (downsec == 0) {  
28 - that.setData({  
29 - downsec: '60',  
30 - codetxt: '获取验证码'  
31 - })  
32 - //这里特别要注意,计时器是始终一直在走的,如果你的时间为0,那么就要关掉定时器!不然相当耗性能  
33 - //因为timer是存在data里面的,所以在关掉时,也要在data里取出后再关闭  
34 - clearInterval(that.data.timer);  
35 - //关闭定时器之后,可作其他处理codes go here  
36 - }  
37 - }, 1000)  
38 - })  
39 - },  
40 - goindex(){  
41 - wx.switchTab({url: '/pages/index/index',})  
42 -  
43 - },  
44 - /**  
45 - * 生命周期函数--监听页面加载  
46 - */  
47 - onLoad: function (options) {  
48 -  
49 - },  
50 -  
51 - /**  
52 - * 生命周期函数--监听页面初次渲染完成  
53 - */  
54 - onReady: function () {  
55 -  
56 - },  
57 -  
58 - /**  
59 - * 生命周期函数--监听页面显示  
60 - */  
61 - onShow: function () {  
62 -  
63 - },  
64 -  
65 - /**  
66 - * 生命周期函数--监听页面隐藏  
67 - */  
68 - onHide: function () {  
69 -  
70 - }, 5 + /**
  6 + * 页面的初始数据
  7 + */
  8 + data: {
  9 + timer: '', //定时器名字
  10 + codetxt: '获取验证码',
  11 + downsec: 60, //倒计时初始值
  12 + mobile: "",
  13 + code: "",
  14 + imgUrl: app.globalData.imgUrl
  15 + },
  16 +
  17 + //倒计时
  18 + downsec() {
  19 + let that = this;
  20 + let downsec = that.data.downsec;
  21 + if(that.data.mobile == "") {
  22 + wx.showToast({
  23 + title: '请输入手机号!',
  24 + icon: 'none',
  25 + duration: 1300
  26 + })
  27 + return false;
  28 + }
  29 + if(that.data.mobile.length != 11) {
  30 + wx.showToast({
  31 + title: '手机号长度有误!',
  32 + icon: 'none',
  33 + duration: 1300
  34 + })
  35 + return false;
  36 + }
  37 + var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1}))+\d{8})$/;
  38 + if (!myreg.test(that.data.mobile)) {
  39 + wx.showToast({
  40 + title: '请输入正确的手机号!',
  41 + icon: 'none',
  42 + duration: 1300
  43 + })
  44 + return false;
  45 + }
  46 + let u = "wxapp/public/getCode";
  47 + let data = {
  48 + mobile: that.data.mobile
  49 + }
  50 + app.post(u,data).then((r) => {
  51 + console.log(r);
  52 + if (r.code == 20000) {
  53 + if (downsec == 60)
  54 + that.setData({
  55 + timer: setInterval(function () { //这里把setInterval赋值给变量名为timer的变量
  56 + //每隔一秒countDownNum就减一,实现同步
  57 + downsec--;
  58 + //然后把countDownNum存进data,好让用户知道时间在倒计着
  59 + that.setData({
  60 + downsec: downsec,
  61 + codetxt: downsec + 's'
  62 + })
  63 + //在倒计时还未到0时,这中间可以做其他的事情,按项目需求来
  64 + if (downsec == 0) {
  65 + that.setData({
  66 + downsec: '60',
  67 + codetxt: '获取验证码'
  68 + })
  69 + //这里特别要注意,计时器是始终一直在走的,如果你的时间为0,那么就要关掉定时器!不然相当耗性能
  70 + //因为timer是存在data里面的,所以在关掉时,也要在data里取出后再关闭
  71 + clearInterval(that.data.timer);
  72 + //关闭定时器之后,可作其他处理codes go here
  73 + }
  74 + }, 1000)
  75 + })
  76 + }
  77 + }).catch((err) => {
  78 +
  79 + })
  80 +
  81 + },
  82 +
  83 + // 手机号同步到data
  84 + bindMobile(e) {
  85 + this.setData({
  86 + mobile: e.detail.value.replace(/\s+/g, '')
  87 + })
  88 + },
  89 +
  90 + // 验证码同步到data
  91 + codeFun(e) {
  92 + this.setData({
  93 + code: e.detail.value.replace(/\s+/g, '')
  94 + })
  95 + },
  96 +
  97 + // 进入首页
  98 + goindex() {
  99 + let t = this;
  100 + let data = {
  101 + mobile: t.data.mobile,
  102 + code: t.data.code,
  103 + type: 1
  104 + }
  105 + let u = "wxapp/public/lineMobile";
  106 + let header = {
  107 + "XX-Token": wx.getStorageSync("token")
  108 + }
  109 + app.post(u, data,header).then((r) => {
  110 + console.log(r);
  111 + // wx.switchTab({
  112 + // url: '/pages/index/index',
  113 + // })
  114 + }).catch((err) => {
  115 +
  116 + })
  117 +
  118 +
  119 + },
  120 + /**
  121 + * 生命周期函数--监听页面加载
  122 + */
  123 + onLoad: function(options) {
  124 +
  125 + },
  126 +
  127 + /**
  128 + * 生命周期函数--监听页面初次渲染完成
  129 + */
  130 + onReady: function() {
  131 +
  132 + },
  133 +
  134 + /**
  135 + * 生命周期函数--监听页面显示
  136 + */
  137 + onShow: function() {
  138 +
  139 + },
  140 +
  141 + /**
  142 + * 生命周期函数--监听页面隐藏
  143 + */
  144 + onHide: function() {
  145 +
  146 + },
  147 +
  148 + /**
  149 + * 生命周期函数--监听页面卸载
  150 + */
  151 + onUnload: function() {
  152 +
  153 + },
  154 +
  155 + /**
  156 + * 页面相关事件处理函数--监听用户下拉动作
  157 + */
  158 + onPullDownRefresh: function() {
  159 +
  160 + },
  161 +
  162 + /**
  163 + * 页面上拉触底事件的处理函数
  164 + */
  165 + onReachBottom: function() {
  166 +
  167 + },
  168 +
  169 + /**
  170 + * 用户点击右上角分享
  171 + */
  172 + onShareAppMessage: function() {
71 173
72 - /**  
73 - * 生命周期函数--监听页面卸载  
74 - */  
75 - onUnload: function () {  
76 -  
77 - },  
78 -  
79 - /**  
80 - * 页面相关事件处理函数--监听用户下拉动作  
81 - */  
82 - onPullDownRefresh: function () {  
83 -  
84 - },  
85 -  
86 - /**  
87 - * 页面上拉触底事件的处理函数  
88 - */  
89 - onReachBottom: function () {  
90 -  
91 - },  
92 -  
93 - /**  
94 - * 用户点击右上角分享  
95 - */  
96 - onShareAppMessage: function () {  
97 -  
98 - } 174 + }
99 }) 175 })
1 <!--pages/login/login.wxml--> 1 <!--pages/login/login.wxml-->
2 <view class='my_content'> 2 <view class='my_content'>
3 - <image src='../../../imgs/denglubviejing@3x.png'></image>  
4 - <view class='login_box'>  
5 - <view class='input_item'>  
6 - <input placeholder='绑定手机' placeholder-class='input_place'></input>  
7 - </view>  
8 - <view class='input_item'>  
9 - <input placeholder='输入手机号' placeholder-class='input_place'></input>  
10 - </view>  
11 - <view class='input_item code'>  
12 - <input placeholder='绑定手机' placeholder-class='input_place'></input>  
13 - <view class='code_txt' bindtap='downsec'>{{codetxt}}</view>  
14 - </view>  
15 - <view class='agree'>  
16 - <text class='iconfont icon-duigou'></text> 已阅读  
17 - <navigator class='agree_txt'url='/pages/img_txt/img_txt' hover-class="none">《用户注册协议》</navigator>  
18 - </view>  
19 - <view class='goindex' bindtap='goindex'>  
20 - <view class='goindex_txt' >进入首页</view>  
21 - </view>  
22 - </view> 3 + <image src='{{imgUrl}}denglubviejing@3x.png'></image>
  4 + <view class='login_box'>
  5 + <view class='input_item'>
  6 + 绑定手机
  7 + <!-- <input placeholder='绑定手机' placeholder-class='input_place'></input> -->
  8 + </view>
  9 + <view class='input_item'>
  10 + <input placeholder='输入手机号' type='number' maxlength='11' bindinput='bindMobile' placeholder-class='input_place'></input>
  11 + </view>
  12 + <view class='input_item code'>
  13 + <input placeholder='输入验证码' type='number' bindinput='codeFun' placeholder-class='input_place'></input>
  14 + <view class='code_txt' bindtap='downsec'>{{codetxt}}</view>
  15 + </view>
  16 + <view class='agree'>
  17 + <text class='iconfont icon-duigou'></text> 已阅读
  18 + <navigator class='agree_txt' url='/pages/img_txt/img_txt' hover-class="none">《用户注册协议》</navigator>
  19 + </view>
  20 + <view class='goindex' bindtap='goindex'>
  21 + <view class='goindex_txt'>进入首页</view>
  22 + </view>
  23 + </view>
23 24
24 -</view> 25 +</view>
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 <image src='../../../imgs/shenaghudenglubeijing@3x.png'></image> 3 <image src='../../../imgs/shenaghudenglubeijing@3x.png'></image>
4 <view class='login_box'> 4 <view class='login_box'>
5 <view class='input_item'> 5 <view class='input_item'>
6 - <input placeholder='绑定手机' placeholder-class='input_place'></input> 6 + <input placeholder='绑定手机' readonly="readonly" placeholder-class='input_place'></input>
7 </view> 7 </view>
8 <view class='input_item'> 8 <view class='input_item'>
9 <input placeholder='输入手机号' placeholder-class='input_place'></input> 9 <input placeholder='输入手机号' placeholder-class='input_place'></input>
1 /* pages/login/login.wxss */ 1 /* pages/login/login.wxss */
2 -page{  
3 - background: #010938; 2 +
  3 +page {
  4 + background: #010938;
4 } 5 }
5 -.login_box{  
6 - position: absolute;  
7 - top:0;  
8 - left:50%;  
9 - transform: translateX(-50%);  
10 - overflow-y: scroll;  
11 - height: 100%;  
12 -width:530rpx;  
13 -margin: 170rpx auto 0 auto;  
14 -color:#fff;  
15 -font-size:28rpx; 6 +
  7 +.login_box {
  8 + position: absolute;
  9 + top: 0;
  10 + left: 50%;
  11 + transform: translateX(-50%);
  12 + /* overflow-y: scroll; */
  13 + height: 100%;
  14 + width: 530rpx;
  15 + margin: 170rpx auto 0 auto;
  16 + color: #fff;
  17 + font-size: 28rpx;
16 } 18 }
17 -.input_item{  
18 - padding:16rpx 0;  
19 - border-bottom:1rpx solid #fff;  
20 - margin: 0 0 26rpx 0; 19 +
  20 +.input_item {
  21 + padding: 16rpx 0;
  22 + border-bottom: 1rpx solid #fff;
  23 + margin: 0 0 26rpx 0;
21 } 24 }
22 -.input_place{  
23 - color:#fff;  
24 - font-size: 28rpx; 25 +
  26 +.input_place {
  27 + color: #fff;
  28 + font-size: 28rpx;
25 } 29 }
26 -.code{  
27 - display: flex;  
28 - justify-content: space-between;  
29 - align-items: center; 30 +
  31 +.code {
  32 + display: flex;
  33 + justify-content: space-between;
  34 + align-items: center;
30 } 35 }
31 36
32 -.code input{  
33 - width:60%; 37 +.code input {
  38 + width: 60%;
34 } 39 }
35 -.code_txt{  
36 - display: flex;  
37 - align-items: center;  
38 - justify-content: center;  
39 - padding:2rpx 10rpx;  
40 - box-sizing: border-box;  
41 - width:178rpx;  
42 - height: 44rpx;  
43 - border:1rpx solid #fff;  
44 - border-radius: 10rpx; 40 +
  41 +.code_txt {
  42 + display: flex;
  43 + align-items: center;
  44 + justify-content: center;
  45 + padding: 5rpx 10rpx 7rpx;
  46 + box-sizing: border-box;
  47 + width: 178rpx;
  48 + height: 44rpx;
  49 + border: 1rpx solid #fff;
  50 + border-radius: 10rpx;
45 } 51 }
46 -.agree{  
47 - display: flex;  
48 - justify-content: center;  
49 - align-items: center; 52 +
  53 +.agree {
  54 + display: flex;
  55 + justify-content: center;
  56 + align-items: center;
50 } 57 }
51 -.agree_txt{  
52 - color:#009FE8; 58 +
  59 +.agree_txt {
  60 + color: #009fe8;
53 } 61 }
54 -.agree .iconfont{  
55 - display: inline-block;  
56 - border:1rpx solid rgba(255,255,255,0.7);  
57 - color:rgba(255,255,255,0.7);  
58 - margin: 0 13rpx 0 0;  
59 - font-size:20rpx;  
60 - border-radius: 33%; 62 +
  63 +.agree .iconfont {
  64 + display: inline-block;
  65 + border: 1rpx solid rgba(255, 255, 255, 0.7);
  66 + color: rgba(255, 255, 255, 0.7);
  67 + margin: 0 13rpx 0 0;
  68 + font-size: 20rpx;
  69 + border-radius: 33%;
  70 +}
  71 +
  72 +.goindex {
  73 + position: fixed;
  74 + padding: 27rpx 0;
  75 + bottom: 300rpx;
  76 + left: 50%;
  77 + transform: translateX(-50%);
  78 + width: 530rpx;
  79 + display: flex;
  80 + justify-items: center;
  81 + justify-content: center;
  82 + border-top: 1rpx solid #fff;
  83 + border-bottom: 1rpx solid #fff;
61 } 84 }
62 -.goindex{  
63 - position: fixed;  
64 - padding:27rpx 0;  
65 - bottom:300rpx;  
66 - left:50%;  
67 - transform: translateX(-50%);  
68 - width: 530rpx;  
69 85
70 - display: flex;  
71 - justify-items: center;  
72 - justify-content: center;  
73 - border-top:1rpx solid #fff;  
74 - border-bottom:1rpx solid #fff; 86 +.goindex_txt {
  87 + padding: 4rpx 20rpx;
  88 + background: rgba(255, 255, 255, 0.7);
  89 + border-radius: 10rpx;
  90 + color: rgba(255, 255, 255, 0.7);
75 } 91 }
76 92
77 -.goindex_txt{  
78 -padding:4rpx 20rpx;  
79 -background: rgba(255,255,255,0.7);  
80 -border-radius: 10rpx;  
81 -color:rgba(255,255,255,0.7); 93 +.goindex_txt::active {
  94 + opacity: 0.7;
82 } 95 }
83 -.goindex_txt::active{  
84 -opacity: 0.7;  
85 -}