Commit 84df9113 authored by Morson's avatar Morson

页面逻辑调整

parent d48597dc
...@@ -30,7 +30,7 @@ npm run build:mp-weixin // 运行生产环境 ...@@ -30,7 +30,7 @@ npm run build:mp-weixin // 运行生产环境
[图片上传参考](https://ext.dcloud.net.cn/plugin?id=822) [图片上传参考](https://ext.dcloud.net.cn/plugin?id=822)
### 自定义配置 ### 自定义配置
...@@ -68,4 +68,21 @@ npm run build:mp-weixin // 运行生产环境 ...@@ -68,4 +68,21 @@ npm run build:mp-weixin // 运行生产环境
``` ```
### 引用token
1. 方式一,存放在vuex的token,假设使用了uView封装的vuex方式
// 见:https://uviewui.com/components/globalVariable.html
// config.header.token = vm.token;
2. 方式二,如果没有使用uView封装的vuex方法,那么需要使用$store.state获取
// config.header.token = vm.$store.state.token;
3. 方式三,如果token放在了globalData,通过getApp().globalData获取
// config.header.token = getApp().globalData.username;
4. 方式四,如果token放在了Storage本地存储中,拦截是每次请求都执行的
// 所以哪怕您重新登录修改了Storage,下一次的请求将会是最新值
// const token = uni.getStorageSync('token');
// config.header.token = token;
PS: 当前项目使用了:方式一,具体情况可以参考state目录下代码
vm.vuex_token
...@@ -4,11 +4,10 @@ import { AnalysysAgent } from "@/utils/analysys_paas.js"; ...@@ -4,11 +4,10 @@ import { AnalysysAgent } from "@/utils/analysys_paas.js";
import util from "@/utils/util.js"; import util from "@/utils/util.js";
import login from "@/utils/login.js"; import login from "@/utils/login.js";
export default { export default {
globalData: { globalData: {
jumpLoginStatus: true,
// 开发环境 // 开发环境
uniEnv: process.uniEnv, uniEnv: process.uniEnv,
// 登录凭证
token: "",
// 微信小程序平台编号,空--家维广场,1--自营平台 // 微信小程序平台编号,空--家维广场,1--自营平台
wxAppNo: 1, wxAppNo: 1,
...@@ -80,10 +79,10 @@ export default { ...@@ -80,10 +79,10 @@ export default {
AnalysysAgent.registerSuperProperty("platform", "self-support"); AnalysysAgent.registerSuperProperty("platform", "self-support");
this.getSystemInfo() this.getSystemInfo()
// 版本更新 // 版本更新
this.updateApp(); await this.updateApp();
// 系统自动登录 // 系统自动登录
this.autoLogin(); await this.autoLogin();
}, },
onShow: async function () { onShow: async function () {
// 应用启动,或从后台进入前台显示 // 应用启动,或从后台进入前台显示
...@@ -177,7 +176,7 @@ export default { ...@@ -177,7 +176,7 @@ export default {
}, },
/* 版本更新 */ /* 版本更新 */
updateApp() { async updateApp() {
// 版本更新 // 版本更新
const updateManager = uni.getUpdateManager(); const updateManager = uni.getUpdateManager();
......
...@@ -16,10 +16,7 @@ const install = (Vue, vm) => { ...@@ -16,10 +16,7 @@ const install = (Vue, vm) => {
function toLoginPage(){ function toLoginPage(){
const app = getApp() const app = getApp()
let jumpLoginStatus let jumpLoginStatus = app && app.globalData && app.globalData.jumpLoginStatus
if(app && app.globalData){
jumpLoginStatus = app.globalData.jumpLoginStatus
}
if(!jumpLoginStatus){ if(!jumpLoginStatus){
return return
} }
......
...@@ -29,11 +29,11 @@ ...@@ -29,11 +29,11 @@
<view class="select-time u-p-t-50"> <view class="select-time u-p-t-50">
<view class="u-flex u-row-between"> <view class="u-flex u-row-between">
<view class="txt">选择时间:</view> <view class="txt">选择时间:</view>
<view class="txt active">{{ currentTimeTxt }}</view> <view class="txt active">{{ appointRangeText }}</view>
</view> </view>
<view class="u-p-t-30 u-flex u-flex-wrap time-list"> <view class="u-p-t-30 u-flex u-flex-wrap time-list">
<view <view
:class="{'time-item':true,'active': index===currentTime}" v-for="(item,index) in timeList" :class="{'time-item':true,'active': item.pkey===appointRange}" v-for="(item,index) in timeList"
:key="item.pkey"> :key="item.pkey">
<button class="time" :plain="true" <button class="time" :plain="true"
:disabled="item.disabled" :hair-line="false" :disabled="item.disabled" :hair-line="false"
...@@ -63,6 +63,7 @@ ...@@ -63,6 +63,7 @@
return "预约时间" return "预约时间"
} }
}, },
dateList: { dateList: {
type: Array, type: Array,
default(){ default(){
...@@ -96,30 +97,21 @@ ...@@ -96,30 +97,21 @@
}, },
data() { data() {
return { return {
currentDay: null,
currentTime: null,
appointTime: null, appointTime: null,
appointRange: "", appointRange: null,
appointRangeText: '',
num: 0, num: 0,
hasLast: false hasLast: false
} }
}, },
watch: { watch: {
title() { title() {
this.currentDay = null
this.currentTime = null
this.appointTime = null this.appointTime = null
this.appointRange = "" this.appointRange = null
this.appointRangeText = ''
} }
}, },
computed: { computed: {},
currentTimeTxt() {
if(this.currentTime != null) {
return this.timeList[this.currentTime].name
}
return ''
},
},
methods: { methods: {
getDateList() { getDateList() {
// 获取日期 // 获取日期
...@@ -130,10 +122,9 @@ ...@@ -130,10 +122,9 @@
index, index,
list, list,
} }
this.currentDay = index
this.appointTime = item.day this.appointTime = item.day
this.currentTime = null this.appointRange = null
this.appointRange = "" this.appointRangeText = ''
this.$emit('date-change', data) this.$emit('date-change', data)
}, },
timeChange(item, index, list) { timeChange(item, index, list) {
...@@ -142,8 +133,8 @@ ...@@ -142,8 +133,8 @@
index, index,
list, list,
} }
this.currentTime = index
this.appointRange = item.pkey this.appointRange = item.pkey
this.appointRangeText = item.name
this.$emit('time-change', data) this.$emit('time-change', data)
}, },
weekChange(item, index, list) { weekChange(item, index, list) {
...@@ -246,8 +237,6 @@ ...@@ -246,8 +237,6 @@
} }
&.active { &.active {
// background-color: #2272FF;
.day { .day {
color: #2272FF; color: #2272FF;
......
...@@ -118,8 +118,8 @@ export default { ...@@ -118,8 +118,8 @@ export default {
appointTitle: '预约时间', appointTitle: '预约时间',
appoint: ['下次联系时间', '预约时间'], appoint: ['下次联系时间', '预约时间'],
trace: { trace: {
reasonType: '报', // 反馈类型 reasonType: '报', // 反馈类型
reasonRelegation: '', // 反馈归属 reasonRelegation: '客户', // 反馈归属
reason: '', // 反馈原因 reason: '', // 反馈原因
appointmentDatetime: null, // 预约时间 appointmentDatetime: null, // 预约时间
appointmentDatetimeRange: '', // 预约时间段类型 appointmentDatetimeRange: '', // 预约时间段类型
...@@ -146,13 +146,15 @@ export default { ...@@ -146,13 +146,15 @@ export default {
computed: { computed: {
disabledSubmit() { disabledSubmit() {
let self = this; let self = this;
if (self.trace.reasonType && self.trace.reasonType == '报备') { if(self.trace.reasonRelegation && self.trace.reason) {
if (self.trace.reasonRelegation && self.trace.reason && self.trace.nextTraceDatetime && self.trace.appointmentDatetimeRange) { if (self.trace.reasonType == '改约') {
return false; if (self.trace.appointmentDatetime && self.trace.appointmentDatetimeRange) {
} return false;
} else if (self.trace.reasonType && self.trace.reasonType == '改约') { }
if (self.trace.reasonRelegation && self.trace.reason && self.trace.appointmentDatetime && self.trace.appointmentDatetimeRange) { } else {
return false; if (self.trace.nextTraceDatetime && self.trace.appointmentDatetimeRange) {
return false;
}
} }
} }
...@@ -197,7 +199,7 @@ export default { ...@@ -197,7 +199,7 @@ export default {
configs[index] = { name: tab, owns: [] }; configs[index] = { name: tab, owns: [] };
if(tab == '改约') { if(tab == '改约') {
self.appoint[index] = '预约时间' self.appoint[index] = '预约时间'
} else if(tab == '报备') { } else {
self.appoint[index] = '下次联系时间' self.appoint[index] = '下次联系时间'
} }
owns.forEach(function(own, key) { owns.forEach(function(own, key) {
...@@ -220,6 +222,9 @@ export default { ...@@ -220,6 +222,9 @@ export default {
self.trace.reason = tabList['owns'][self.curOwn]['types'][0]; self.trace.reason = tabList['owns'][self.curOwn]['types'][0];
self.appointTitle = self.appoint[self.curTab] self.appointTitle = self.appoint[self.curTab]
self.trace.remark = ''; self.trace.remark = '';
self.trace.appointmentDatetime = null;
self.trace.appointmentDatetimeRange = null;
self.trace.nextTraceDatetime = null;
if (self.trace.reasonType == '改约') { if (self.trace.reasonType == '改约') {
self.showRemark = true; self.showRemark = true;
if (self.dateList && self.timeList) { if (self.dateList && self.timeList) {
...@@ -298,13 +303,7 @@ export default { ...@@ -298,13 +303,7 @@ export default {
console.log(data, 'week-data'); console.log(data, 'week-data');
let self = this; let self = this;
self.dateItem = data.item self.dateItem = data.item
if (self.trace.reasonType == '报备') { if (self.trace.reasonType == '改约') {
self.trace.appointmentDatetime = null;
self.trace.nextTraceDatetime = data.item.day;
self.timeList.map((item, index) => {
item.disabled = false;
});
} else if (self.trace.reasonType == '改约') {
self.trace.appointmentDatetime = data.item.day; self.trace.appointmentDatetime = data.item.day;
self.trace.nextTraceDatetime = null; self.trace.nextTraceDatetime = null;
self.timeList.map((item, index) => { self.timeList.map((item, index) => {
...@@ -314,6 +313,12 @@ export default { ...@@ -314,6 +313,12 @@ export default {
item.disabled = false; item.disabled = false;
} }
}); });
} else {
self.trace.appointmentDatetime = null;
self.trace.nextTraceDatetime = data.item.day;
self.timeList.map((item, index) => {
item.disabled = false;
});
} }
self.trace.appointmentDatetimeRange = ''; self.trace.appointmentDatetimeRange = '';
}, },
...@@ -334,8 +339,28 @@ export default { ...@@ -334,8 +339,28 @@ export default {
} }
self.submiting = true; self.submiting = true;
let res = await self.$u.api.traceAndAppointment(self.trace, self.orderId); let params = this.$u.deepClone(self.trace);
if(self.trace.reasonType != '改约') {
params.appointmentDatetimeRange = null
params.appointmentDatetime = null
if(self.timeItem && self.timeItem.pkey && params.nextTraceDatetime){
let traceDate = self.moment(params.nextTraceDatetime);
let timeArr = self.timeItem.pkey.split("_")
let hours = timeArr && timeArr.length && timeArr.pop()
let traceDateTime = traceDate.clone().add(Number(hours), 'hours');
params.nextTraceDatetime = traceDateTime.unix() * 1000
}
}
let res = await self.$u.api.traceAndAppointment(params, self.orderId);
self.submiting = false; self.submiting = false;
if(res && res.code == 200) {
self.$u.route({
url: 'pages/order/detail',
params: {
id: self.orderId
}
})
}
} }
} }
}; };
...@@ -493,4 +518,11 @@ export default { ...@@ -493,4 +518,11 @@ export default {
.width-320 { .width-320 {
width: 320rpx; width: 320rpx;
} }
/deep/ button[plain] {
border: none;
}
button[disabled]:not([type]) {
background: #d1d4d4;
color: #ffffff;
}
</style> </style>
...@@ -2,21 +2,21 @@ var t = function(t) { ...@@ -2,21 +2,21 @@ var t = function(t) {
return (t = t.toString())[1] ? t : "0" + t; return (t = t.toString())[1] ? t : "0" + t;
}; };
const getToken = function(){ // const getToken = function(){
const app = getApp() // const app = getApp()
let token = app && app.globalData && app.globalData.token || '' // let token = app && app.globalData && app.globalData.token || ''
if(!token){ // if(!token){
token = uni.getStorageSync('token') // token = uni.getStorageSync('token')
} // }
return token // return token
} // }
const setToken = function(token){ // const setToken = function(token){
const app = getApp() // const app = getApp()
uni.setStorageSync('token',token) // uni.setStorageSync('token',token)
if(app && app.globalData){ // if(app && app.globalData){
app.globalData.token = token // app.globalData.token = token
} // }
} // }
const getOpenid = function(){ const getOpenid = function(){
const app = getApp() const app = getApp()
...@@ -54,8 +54,8 @@ module.exports = { ...@@ -54,8 +54,8 @@ module.exports = {
o = o.substring(0, e), e = (i = 60 * i + "").indexOf("."), i = i.substring(0, e + 4), o = o.substring(0, e), e = (i = 60 * i + "").indexOf("."), i = i.substring(0, e + 4),
i = parseFloat(i).toFixed(0)) : 1 == n && (o = parseFloat(o).toFixed(6))), 2 == n ? r + "°" + o + "′" + i + "″" : 1 == n ? r + "°" + o + "′" : void 0; i = parseFloat(i).toFixed(0)) : 1 == n && (o = parseFloat(o).toFixed(6))), 2 == n ? r + "°" + o + "′" + i + "″" : 1 == n ? r + "°" + o + "′" : void 0;
}, },
getToken, // getToken,
setToken, // setToken,
getOpenid, getOpenid,
setOpenid, setOpenid,
}; };
\ No newline at end of file
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