Commit a9333c14 by zhangxw

1

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