From df61667b38417e6398c970f6dcecb4d2f7aa5175 Mon Sep 17 00:00:00 2001 From: initwithout Date: Fri, 21 Apr 2023 10:03:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=B6=88=E6=81=AF=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=20=E7=99=BB=E5=BD=95=E6=A8=A1=E5=BC=8F=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=96=B0=E5=A2=9E=E5=BE=AE=E4=BF=A1=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/login/login.js | 61 +++++++++++++++++++++++++++++------------- pages/login/login.wxml | 8 +++--- pages/order/order.wxml | 16 +++++------ pages/order/pay.js | 17 +++++++++--- pages/order/pay.wxml | 6 ++--- pages/order/pay.wxss | 11 ++++---- pages/user/user.js | 13 +++------ utils/server.js | 3 +++ 8 files changed, 83 insertions(+), 52 deletions(-) diff --git a/pages/login/login.js b/pages/login/login.js index 30f2bf5..84e0e52 100644 --- a/pages/login/login.js +++ b/pages/login/login.js @@ -12,6 +12,8 @@ Page({ thvm:{}, account: '', password: '', + code: "", + tmplIds: [], }, //密码登录to验证码登录 switchTab: function(e) { @@ -67,25 +69,47 @@ Page({ }) } }, - wxlogin(){ + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + this.reloadData() + }, + reloadData() { + var that = this wx.login({ success: function (res) { - WXAPI.wxLogin({ - code: res.code, + var code = res.code; + that.setData({ + code: code, + }) + WXAPI.getWXTemplates({ + code: code, storeId: 239, }).then(res => { if (res.code == 200) { - var data = res.data - app.globalData.accessId = data.access_id; - wx.setStorageSync('accessId', data.access_id) - wx.setStorageSync('isLogin', true); - wx.setStorageSync('userInfo', data.user); - wx.navigateBack() + wx.setStorageSync('tmplIds', res.data.templates) } }) } }); }, + // wxlogin(){ + // var that = this + // WXAPI.wxLogin({ + // code: that.data.code, + // storeId: 239, + // }).then(res => { + // if (res.code == 200) { + // var data = res.data + // app.globalData.accessId = data.access_id; + // wx.setStorageSync('accessId', data.access_id) + // wx.setStorageSync('isLogin', true); + // wx.setStorageSync('userInfo', data.user); + // wx.navigateBack() + // } + // }) + // }, //授权微信手机号 bindPhoneNumber: function(e) { var that = this; @@ -109,16 +133,9 @@ Page({ }, //微信一键登录 tapWeixinLogin : function(e) { - var code = e.detail.code - console.log(code) - wx.showModal({ - title:'警告', - content:code, - showCancel:false, - confirmText:'返回授权', - }) + var that = this WXAPI.wxLogin({ - code: code, + code: that.data.code, storeId: 239, }).then(res => { if (res.code == 200) { @@ -126,10 +143,16 @@ Page({ app.globalData.accessId = data.access_id; wx.setStorageSync('accessId', data.access_id) wx.setStorageSync('isLogin', true); - wx.setStorageSync('userInfo', data.data); + wx.setStorageSync('userInfo', data.user); wx.navigateBack() } }) + }, + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + }, accountInput: function(e) { this.setData({ diff --git a/pages/login/login.wxml b/pages/login/login.wxml index ede81f9..33d104f 100644 --- a/pages/login/login.wxml +++ b/pages/login/login.wxml @@ -27,12 +27,12 @@ 其他登陆方式 - + + --> + 微信登录 diff --git a/pages/order/order.wxml b/pages/order/order.wxml index 111b950..a61c1bb 100644 --- a/pages/order/order.wxml +++ b/pages/order/order.wxml @@ -35,21 +35,21 @@ - 取消订单 - 立即付款 + 取消订单 + 立即付款 提醒发货 - 提醒发货 + 提醒发货 - 查看物流 - 确认收货 + 查看物流 + 确认收货 - 删除订单 - 查看物流 - 立即评价 + 删除订单 + 查看物流 + 立即评价 diff --git a/pages/order/pay.js b/pages/order/pay.js index 7248313..5a65e7c 100644 --- a/pages/order/pay.js +++ b/pages/order/pay.js @@ -73,10 +73,9 @@ Page({ }, onLoad: function (options) { - console.log(options) + // console.log(options) var that = this; // that.get_plug(); - var uid = app.globalData.userInfo.openid; // 微信id var plug_ins = app.globalData.userInfo.plug_ins; // 插件 var coupon = app.globalData.userInfo.coupon; // 优惠券状态 @@ -85,7 +84,7 @@ Page({ cartId: options.cartId, // 购物车id num1: options.num, type: options.type ? options.type : 0, //(1.直接结算 0购物车结算) - bgcolor: '#FF6347', // 背景颜色 + bgcolor: '#FA5151', // 背景颜色 userId: uid, // 微信id plug_ins: plug_ins, // 插件 coupon: coupon, // 优惠券状态 @@ -421,9 +420,21 @@ Page({ } } }, + // 订阅消息 + subscribeMessage() { + var tmplIds = wx.getStorageSync('tmplIds') + console.log(tmplIds) + wx.requestSubscribeMessage({ + tmplIds: tmplIds, + success (res) { + console.log(res); + } + }) + }, // 提交订单支付 createProductOrderByWX: function (e) { var that = this; + that.subscribeMessage() // if (that.data.ispayOrder) { // return // } diff --git a/pages/order/pay.wxml b/pages/order/pay.wxml index 6140078..29f8c12 100644 --- a/pages/order/pay.wxml +++ b/pages/order/pay.wxml @@ -25,7 +25,7 @@ - + @@ -125,8 +125,8 @@ 合计: ¥ {{total}} - - + + diff --git a/pages/order/pay.wxss b/pages/order/pay.wxss index ec6230f..ee01a9c 100644 --- a/pages/order/pay.wxss +++ b/pages/order/pay.wxss @@ -144,7 +144,7 @@ width: 100%; padding:10px; } .btn_zf{ -background:#ff6347; +background:#fa5151; color:#fff !important; width:35%; height:52px; @@ -164,8 +164,7 @@ dl{ } dt{ padding:10px 0; -display:block; - + display:block; } li{ font-size: 14px; line-height: 34px;color: #575757;height: 34px;display: block;padding-left: 10px; @@ -393,7 +392,7 @@ line-height:30px; border-bottom: 1px solid #eee; } .gb_fr{ - background:red; + background:#FA5151; width:20px; height:20px; border-radius:50%; @@ -705,7 +704,7 @@ margin:10px auto; } .coupon_right{ width:22%; -background:#ff6347; +background:#FA5151; position:relative; height:120px; text-align:center; @@ -804,7 +803,7 @@ left:-13px; width: 30%; overflow: hidden; font-size: 13px; - color: #fc0628; + color: #FA5151; } .guige{ margin-top: 90rpx; diff --git a/pages/user/user.js b/pages/user/user.js index b00e00b..b9e01b7 100644 --- a/pages/user/user.js +++ b/pages/user/user.js @@ -78,10 +78,10 @@ Page({ that.setData({ remind: '' }); - }, + }, onShow: function () { - var cont = this.data.cont; - var that = this; + var that = this; + var cont = that.data.cont; if (cont > 1) { that.requestMyData(); } else { @@ -89,14 +89,9 @@ Page({ cont: cont + 1 }) } - }, - + }, requestMyData: function () { var that = this; - // WXAPI.appIndex({ - - // }) - WXAPI.userIndex({ accessId: app.globalData.accessId, storeId: 239, diff --git a/utils/server.js b/utils/server.js index f2ee927..c2fdd2d 100644 --- a/utils/server.js +++ b/utils/server.js @@ -65,6 +65,9 @@ module.exports = { logout: (data) => { //退出登录 return requestServer('&action=login&app=quit', 'post', data) }, + getWXTemplates: (data) => { //获取订阅消息模板 + return requestServer('&action=message&app=getWXTemplates', 'post', data) + }, /* 首页 */ homeIndex: (data) => { //首页 return requestServer('&action=index&app=index', 'post', data)