Commit a69592a1 by zhangzhen

用户登录优化

parent 429ca7ba
......@@ -16,6 +16,8 @@ http.interceptor.request = (config => {
if (tokenHeaders) {
config.header[tokenHeaders] = uni.getStorageSync(tokenHeaders);
}else{
config.header['Authori-zation'] = ''
}
let data = config.data;
......@@ -72,11 +74,26 @@ http.interceptor.response = (config) => {
/\/chessCards\/consumeByUser/g
]
// if (urls.some(item => item.test(config.config.url)) && config.data.code == 401) {
// uni.navigateTo({
// url: '/pages/login/login'
// })
// }
if (config.data.code == 401) {
// wx.login({
// success: (res) => {
// console.log(343444)
// let url=`/wechat/authorize/program/login?code=`+res.code
// http.post(url,res.code).then(res => {
// if (res.data.code == 200) {
// if (res.data.data.type === "login") {
// uni.setStorageSync('tokenHeaders', "Authori-zation")
// uni.setStorage({
// key: uni.getStorageSync('tokenHeaders'),
// data: res.data.data.token
// })
// }
// }
// })
// }
// })
}
if (![401, 200, 500].includes(config.data.code)) {
uni.showToast({
icon: "none",
......
......@@ -49,6 +49,10 @@
uni.removeStorageSync('tokenHeaders')
this.$refs.popupPhone.open();
}
}else{
setTimeout(()=>{
that.open()
},300)
}
})
}
......
......@@ -691,7 +691,7 @@
this.onUpdateIntervalList()
},
// 更新时间的选取状态
onUpdateIntervalList() {
async onUpdateIntervalList() {
this.useDateStatus = true
let start = Number(this.startTime.split(":")[0])
......@@ -709,7 +709,7 @@
}else if(this.orderType ==1 && end <= start) {
end += 24
}
this.dateObj = this.onSetDateTime(this.startTime, this.endTime);
this.dateObj = await this.onSetDateTime(this.startTime, this.endTime);
this.onGetUseCoupon()
// 重新将数据还原到元数据
this.intervalList = [
......@@ -753,13 +753,12 @@
preStartDate: this.dateObj.startDate,
preEndDate: this.dateObj.endDate
}).then(res => {
if (res.data.code == 200) {
if (res.data && res.data.data.length) {
this.useCouponList = res.data.data.filter(item => item.isAvailable === 0).sort((a,
b) => b.subPrice - a.subPrice);
}
} else if (res.data.code == 200) {
} else if (res.data.code == 401) {
this.$refs.loginPop.open();
}
this.onComputePrice();
......@@ -834,7 +833,7 @@
this.distanceIndex = 0;
this.onSetEndTime()
},
onChangeMode(i) {
async onChangeMode(i) {
if (this.modeIndex === i) return;
this.modeIndex = i;
this.duration = Number(this.packageMode[this.modeIndex].duration);
......@@ -874,7 +873,7 @@
})
}
// this.onComputePrice();
this.dateObj = this.onSetDateTime(this.startTime, this.endTime);
this.dateObj = await this.onSetDateTime(this.startTime, this.endTime);
this.onGetUseCoupon()
},
onDurationChange(i) {
......@@ -1125,7 +1124,7 @@
}
},
// 将时间转换成完整日期
onSetDateTime(startTime, endTime) {
onSetDateTime(startTime, endTime) {
let obj = {
startDate: "",
endDate: ''
......
......@@ -107,7 +107,7 @@
<u-loadmore :status="status" :icon="true" :line='true' :loading-text="loadingText"
:loadmore-text="loadmoreText" :nomore-text="nomoreText" />
</view>
<NoLogin v-model="loginStatus" />
<NoLogin v-model="loginStatus" @success="onLoading" />
<f-tabbar></f-tabbar>
</view>
</template>
......@@ -115,7 +115,7 @@
<script>
import config from "@/config/index.config"
import fTabbar from '@/components/module/f-tabbar/f-tabbar';
import {dictList} from "@/api/index.js";
import {dictList,login} from "@/api/index.js";
import {
orderList
} from "@/api/order.js"
......@@ -217,6 +217,7 @@ import NoLogin from "@/components/noLogin/noLogin"
orderList(this.queryParams).then(res => {
uni.hideLoading()
if (res.data.code == 200) {
this.loginStatus = true
let list =res.data.rows.map(item=>{
return {
...item,
......@@ -235,10 +236,38 @@ import NoLogin from "@/components/noLogin/noLogin"
this.status = 'nomore'
}
}else if(res.data.code == 401){
this.loginStatus = false
this.onLogin()
}
})
},
onLogin(){
let that = this;
wx.login({
success: (res) => {
login(res.code).then(res => {
if (res.data.code == 200) {
if (res.data.data.type === "login") {
uni.setStorageSync('tokenHeaders', "Authori-zation")
uni.setStorage({
key: uni.getStorageSync('tokenHeaders'),
data: res.data.data.token
})
setTimeout(()=>{
that.queryParams.pageNum = 1
that.onLoading()
},300)
} else {
uni.removeStorageSync('tokenHeaders')
this.loginStatus = false
}
}else{
that.onLogin()
}
})
}
})
},
tabSelect(i) {
this.statusIndex = i;
this.queryParams.pageNum = 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment