Commit a9333c14 by zhangxw

1

1 parent aafbf6fe
......@@ -78,20 +78,28 @@ class Request {
},
data
} = response
if (returnAll) {
resolve(data)
return
}
if (code == 20 || code == 21) {
wx.p.storage.rm('userInfo')
wx.p.storage.rm('sessionId')
wx.p.storage.rm('channelSource')
wx.hideLoading()
// session过期跳转到登录页
wx.p.router.reLaunch('/pages/Login/Login')
const thisPage = wx.p.router.getPageInstance(),
options = Object.keys(thisPage.options)
let currentRoute = thisPage.route,
query = []
if (options.length) {
options.map(key => {
query.push(`${key}=${thisPage.options[key]}`)
})
}
if (query.length) currentRoute += `?${query.join('&')}`
return wx.p.router.redirectTo('/pages/loading/loading', {
url: `/${currentRoute}`
})
} else {
if (code == '0') {
if (returnAll) {
resolve(data)
} else {
resolve(data.data)
}
resolve(data.data)
} else {
wx.showToast({
title: message || '系统异常',
......
......@@ -299,8 +299,10 @@ Page({
commonApi.openPointsWallet(walletObj).then(res => {
let { code, message } = res
if (code == 0) {
// 替换钱包昵称
this.replaceNickName({...walletObj})
this.setData({
showEnableSuccess: true,
walletObj
})
} else {
wx.p.wxApi.showToast(message)
}
......@@ -309,7 +311,9 @@ Page({
// 开通成功
successConfirm() {
let { walletObj } = this.data
// 替换钱包昵称
this.replaceNickName({...walletObj})
},
back() {
......
......@@ -25,16 +25,32 @@ Page({
this.login();
},
async login(options = {}) {
if (options.merchantId) wx.$merchant_id = options.merchantId;
try {
const { code, data, message } = await commonApi.getLoginInfo();
const { code, data, message } = await wx.p.api.userApi.login();
if (data)
wx.p.storage.set("merchant_info", {
merchantId: data.merchantId,
merchantName: data.merchantName,
});
if (code == "0") {
wx.p.isLogin = true;
wx.p.storage.set("userInfo", data)
if (!data) throw message
wx.p.storage.set("sessionId", data.sessionId);
// 获取登录信息
commonApi.getLoginInfo().then(res => {
if (res.code == 0) {
} else {
wx.p.isLogin = false;
wx.p.storage.rm("userInfo");
wx.p.storage.rm("sessionId");
}
})
if (!data) throw message;
} else {
wx.p.isLogin = false;
wx.p.storage.rm("userInfo");
wx.p.storage.rm("channelSource")
wx.p.storage.rm("sessionId");
}
console.log("登陆信息:", data);
if (options.url) {
......
......@@ -200,8 +200,7 @@ Page({
let para = {
cartType: 1
}
wx.p.api.shopmallApi
.getShoppingcartList(para)
cartApi.getCartList(para)
.then(data => {
data.map(e => {
e.list.map(i => (i.retailPrice = Number(i.retailPrice).toFixed(2)))
......
......@@ -113,7 +113,6 @@ page {
}
.special-sale-box {
padding: 0 20rpx;
background-color: #F8F9FC;
.item {
width: 100%;
height: 340rpx;
......@@ -161,6 +160,6 @@ page {
}
.sticky {
background: #F9F7F7;
background: #F8F9FC;
padding: 10rpx 0;
}
......@@ -16,6 +16,13 @@
"miniprogram": {
"list": [
{
"name": "pages/Login/Login",
"pathName": "pages/Login/Login",
"query": "",
"scene": null,
"launchMode": "default"
},
{
"name": "积分中心",
"pathName": "packageIndex/pages/integral/index/index",
"query": "",
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!