Browse Source

新增消息通知

登录模式修改新增微信登录
master
杜叶春 2 years ago
parent
commit
df61667b38
  1. 61
      pages/login/login.js
  2. 8
      pages/login/login.wxml
  3. 16
      pages/order/order.wxml
  4. 17
      pages/order/pay.js
  5. 6
      pages/order/pay.wxml
  6. 11
      pages/order/pay.wxss
  7. 13
      pages/user/user.js
  8. 3
      utils/server.js

61
pages/login/login.js

@ -12,6 +12,8 @@ Page({
thvm:{}, thvm:{},
account: '', account: '',
password: '', password: '',
code: "",
tmplIds: [],
}, },
//密码登录to验证码登录 //密码登录to验证码登录
switchTab: function(e) { switchTab: function(e) {
@ -67,25 +69,47 @@ Page({
}) })
} }
}, },
wxlogin(){ /**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.reloadData()
},
reloadData() {
var that = this
wx.login({ wx.login({
success: function (res) { success: function (res) {
WXAPI.wxLogin({ var code = res.code;
code: res.code, that.setData({
code: code,
})
WXAPI.getWXTemplates({
code: code,
storeId: 239, storeId: 239,
}).then(res => { }).then(res => {
if (res.code == 200) { if (res.code == 200) {
var data = res.data wx.setStorageSync('tmplIds', res.data.templates)
app.globalData.accessId = data.access_id;
wx.setStorageSync('accessId', data.access_id)
wx.setStorageSync('isLogin', true);
wx.setStorageSync('userInfo', data.user);
wx.navigateBack()
} }
}) })
} }
}); });
}, },
// 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) { bindPhoneNumber: function(e) {
var that = this; var that = this;
@ -109,16 +133,9 @@ Page({
}, },
//微信一键登录 //微信一键登录
tapWeixinLogin : function(e) { tapWeixinLogin : function(e) {
var code = e.detail.code var that = this
console.log(code)
wx.showModal({
title:'警告',
content:code,
showCancel:false,
confirmText:'返回授权',
})
WXAPI.wxLogin({ WXAPI.wxLogin({
code: code, code: that.data.code,
storeId: 239, storeId: 239,
}).then(res => { }).then(res => {
if (res.code == 200) { if (res.code == 200) {
@ -126,10 +143,16 @@ Page({
app.globalData.accessId = data.access_id; app.globalData.accessId = data.access_id;
wx.setStorageSync('accessId', data.access_id) wx.setStorageSync('accessId', data.access_id)
wx.setStorageSync('isLogin', true); wx.setStorageSync('isLogin', true);
wx.setStorageSync('userInfo', data.data); wx.setStorageSync('userInfo', data.user);
wx.navigateBack() wx.navigateBack()
} }
}) })
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
}, },
accountInput: function(e) { accountInput: function(e) {
this.setData({ this.setData({

8
pages/login/login.wxml

@ -27,12 +27,12 @@
<view class="other-content"> <view class="other-content">
<text class="text3">其他登陆方式</text> <text class="text3">其他登陆方式</text>
<view class="weixinBtn" bindtap="wxlogin"> <!-- <view class="weixinBtn" bindtap="wxlogin">
<image src="/images/weixin.png" mode="aspectFill"></image> <image src="/images/weixin.png" mode="aspectFill"></image>
</view> </view> -->
<!-- <button class="weixinBtn" open-type="getPhoneNumber" bindgetphonenumber="bindPhoneNumber"> <button class="weixinBtn" open-type="getPhoneNumber" bindgetphonenumber="bindPhoneNumber">
<image src="/images/weixin.png" mode="aspectFill"></image> <image src="/images/weixin.png" mode="aspectFill"></image>
</button> --> </button>
<text class="text4">微信登录</text> <text class="text4">微信登录</text>
</view> </view>

16
pages/order/order.wxml

@ -35,21 +35,21 @@
</view> </view>
<view class="bottomView"> <view class="bottomView">
<block wx:if="{{item.status == 0}}"> <block wx:if="{{item.status == 0}}">
<view class="normalBtn" bindtap="removeOrder" data-info="{{item}}">取消订单</view> <view class="normalBtn" catchtap="removeOrder" data-info="{{item}}">取消订单</view>
<view class="confirmBtn" bindtap="payNow" data-info="{{item}}">立即付款</view> <view class="confirmBtn" catchtap="payNow" data-info="{{item}}">立即付款</view>
</block> </block>
<block wx:elif="{{item.status == 1}}"> <block wx:elif="{{item.status == 1}}">
<view class="confirmBtn" wx:if="{{item.delivery_status == 1}}" style="background-color:#ccc;color:white;border:0px;">提醒发货</view> <view class="confirmBtn" wx:if="{{item.delivery_status == 1}}" style="background-color:#ccc;color:white;border:0px;">提醒发货</view>
<view class="confirmBtn" wx:else bindtap="orderRemind" data-info="{{item}}">提醒发货</view> <view class="confirmBtn" wx:else catchtap="orderRemind" data-info="{{item}}">提醒发货</view>
</block> </block>
<block wx:elif="{{item.status == 2}}"> <block wx:elif="{{item.status == 2}}">
<view class="normalBtn" bindtap="orderLogistics" data-info="{{item}}">查看物流</view> <view class="normalBtn" catchtap="orderLogistics" data-info="{{item}}">查看物流</view>
<view class="confirmBtn" bindtap="confirmOrder" data-info="{{item}}">确认收货</view> <view class="confirmBtn" catchtap="confirmOrder" data-info="{{item}}">确认收货</view>
</block> </block>
<block wx:elif="{{item.status == 5}}"> <block wx:elif="{{item.status == 5}}">
<view class="deleteBtn" bindtap="deleteOrder" data-info="{{item}}">删除订单</view> <view class="deleteBtn" catchtap="deleteOrder" data-info="{{item}}">删除订单</view>
<view class="normalBtn" bindtap="orderLogistics" data-info="{{item}}">查看物流</view> <view class="normalBtn" catchtap="orderLogistics" data-info="{{item}}">查看物流</view>
<view class="confirmBtn" bindtap="evaluateOrder" data-info="{{item}}">立即评价</view> <view class="confirmBtn" catchtap="evaluateOrder" data-info="{{item}}">立即评价</view>
</block> </block>
</view> </view>
</view> </view>

17
pages/order/pay.js

@ -73,10 +73,9 @@ Page({
}, },
onLoad: function (options) { onLoad: function (options) {
console.log(options) // console.log(options)
var that = this; var that = this;
// that.get_plug(); // that.get_plug();
var uid = app.globalData.userInfo.openid; // 微信id var uid = app.globalData.userInfo.openid; // 微信id
var plug_ins = app.globalData.userInfo.plug_ins; // 插件 var plug_ins = app.globalData.userInfo.plug_ins; // 插件
var coupon = app.globalData.userInfo.coupon; // 优惠券状态 var coupon = app.globalData.userInfo.coupon; // 优惠券状态
@ -85,7 +84,7 @@ Page({
cartId: options.cartId, // 购物车id cartId: options.cartId, // 购物车id
num1: options.num, num1: options.num,
type: options.type ? options.type : 0, //(1.直接结算 0购物车结算) type: options.type ? options.type : 0, //(1.直接结算 0购物车结算)
bgcolor: '#FF6347', // 背景颜色 bgcolor: '#FA5151', // 背景颜色
userId: uid, // 微信id userId: uid, // 微信id
plug_ins: plug_ins, // 插件 plug_ins: plug_ins, // 插件
coupon: coupon, // 优惠券状态 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) { createProductOrderByWX: function (e) {
var that = this; var that = this;
that.subscribeMessage()
// if (that.data.ispayOrder) { // if (that.data.ispayOrder) {
// return // return
// } // }

6
pages/order/pay.wxml

@ -25,7 +25,7 @@
<!-- 加载页面结束 --> <!-- 加载页面结束 -->
<block wx:else> <block wx:else>
<!--普通结算开始 --> <!--普通结算开始 -->
<view class="w100" style='padding-bottom:100px;' bindtap="createProductOrderByWX"> <view class="w100" style='padding-bottom:100px;'>
<!-- 收货地址 --> <!-- 收货地址 -->
<view class="p_all bg_white mt10 font_14 top_xt" wx:if="{{addrId != ''}}"> <view class="p_all bg_white mt10 font_14 top_xt" wx:if="{{addrId != ''}}">
<view bindtap='go' data-url="../address/index?cartId={{cartId}}" hover-class="none"> <view bindtap='go' data-url="../address/index?cartId={{cartId}}" hover-class="none">
@ -125,8 +125,8 @@
<view class="zhifu mt10 ">合计: <view class="zhifu mt10 ">合计:
<span class="font_20 red" total="{{total}}">¥ {{total}}</span> <span class="font_20 red" total="{{total}}">¥ {{total}}</span>
</view> </view>
<button wx:if="{{pay_xs}}" class="right btn_zf" type="primary" id="{{paytype}}" style='background:{{bgcolor}};border-radius:0;' disabled="{{btnDisabled}}" formType="submit">立即支付</button> <button wx:if="{{pay_xs}}" class="right btn_zf" type="primary" id="{{paytype}}" style='background:#FA5151;;border-radius:0;' disabled="{{btnDisabled}}" formType="submit" bindtap="createProductOrderByWX">立即支付</button>
<button wx:else class="right btn_zf" type="primary" id="{{paytype}}" style='background:{{bgcolor}};border-radius:0;' disabled="{{btnDisabled}}" formType="submit">提交订单</button> <button wx:else class="right btn_zf" type="primary" id="{{paytype}}" style='background:background;border-radius:0;' disabled="{{btnDisabled}}" formType="submit">提交订单</button>
</view> </view>
</view> </view>
</view> </view>

11
pages/order/pay.wxss

@ -144,7 +144,7 @@ width: 100%;
padding:10px; padding:10px;
} }
.btn_zf{ .btn_zf{
background:#ff6347; background:#fa5151;
color:#fff !important; color:#fff !important;
width:35%; width:35%;
height:52px; height:52px;
@ -164,8 +164,7 @@ dl{
} }
dt{ dt{
padding:10px 0; padding:10px 0;
display:block; display:block;
} }
li{ li{
font-size: 14px; line-height: 34px;color: #575757;height: 34px;display: block;padding-left: 10px; 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; border-bottom: 1px solid #eee;
} }
.gb_fr{ .gb_fr{
background:red; background:#FA5151;
width:20px; width:20px;
height:20px; height:20px;
border-radius:50%; border-radius:50%;
@ -705,7 +704,7 @@ margin:10px auto;
} }
.coupon_right{ .coupon_right{
width:22%; width:22%;
background:#ff6347; background:#FA5151;
position:relative; position:relative;
height:120px; height:120px;
text-align:center; text-align:center;
@ -804,7 +803,7 @@ left:-13px;
width: 30%; width: 30%;
overflow: hidden; overflow: hidden;
font-size: 13px; font-size: 13px;
color: #fc0628; color: #FA5151;
} }
.guige{ .guige{
margin-top: 90rpx; margin-top: 90rpx;

13
pages/user/user.js

@ -78,10 +78,10 @@ Page({
that.setData({ that.setData({
remind: '' remind: ''
}); });
}, },
onShow: function () { onShow: function () {
var cont = this.data.cont; var that = this;
var that = this; var cont = that.data.cont;
if (cont > 1) { if (cont > 1) {
that.requestMyData(); that.requestMyData();
} else { } else {
@ -89,14 +89,9 @@ Page({
cont: cont + 1 cont: cont + 1
}) })
} }
}, },
requestMyData: function () { requestMyData: function () {
var that = this; var that = this;
// WXAPI.appIndex({
// })
WXAPI.userIndex({ WXAPI.userIndex({
accessId: app.globalData.accessId, accessId: app.globalData.accessId,
storeId: 239, storeId: 239,

3
utils/server.js

@ -65,6 +65,9 @@ module.exports = {
logout: (data) => { //退出登录 logout: (data) => { //退出登录
return requestServer('&action=login&app=quit', 'post', data) return requestServer('&action=login&app=quit', 'post', data)
}, },
getWXTemplates: (data) => { //获取订阅消息模板
return requestServer('&action=message&app=getWXTemplates', 'post', data)
},
/* 首页 */ /* 首页 */
homeIndex: (data) => { //首页 homeIndex: (data) => { //首页
return requestServer('&action=index&app=index', 'post', data) return requestServer('&action=index&app=index', 'post', data)

Loading…
Cancel
Save