Browse Source

新增功能 客服帮助填写订单

修复问题
添加非全局托管202状态的请求方法
修改统一退出登录选项
master
396316021 2 years ago
parent
commit
1a5f5264bc
  1. 3
      api/draw.js
  2. 22
      api/order.js
  3. 11
      api/user.js
  4. 7
      pages/CardDetail/index.vue
  5. 2
      pages/Coupons/index.vue
  6. 4
      pages/FeedLog/index.vue
  7. 26
      pages/Help/index.vue
  8. 4
      pages/Index/components/OrderPage/index.vue
  9. 13
      pages/Index/components/UserPage/index.vue
  10. 3
      pages/Index/index.vue
  11. 6
      pages/OrderConfirm/end.vue
  12. 430
      pages/OrderDetail/index.vue
  13. 102
      pages/OrderPage/index.vue
  14. 4
      pages/UserCoupons/index.vue
  15. 18
      utils/functions.js
  16. 45
      utils/requestOther.js

3
api/draw.js

@ -1,7 +1,8 @@
import request from "@/utils/request"; import request from "@/utils/request";
import requestOther from "@/utils/requestOther";
export function drawList(){ export function drawList(){
return request({ return requestOther({
url:'draw/drawgoods-list', url:'draw/drawgoods-list',
method:'post', method:'post',
}) })

22
api/order.js

@ -132,7 +132,7 @@ export function orderStart(data){
}) })
} }
/** /**
* 开始服务 * 结束服务
*/ */
export function orderEnd(data){ export function orderEnd(data){
return request({ return request({
@ -141,3 +141,23 @@ export function orderEnd(data){
data:data data:data
}) })
} }
/**
* 保存订单信息
*/
export function orderSave(data){
return request({
url:"order/save",
method: 'post',
data:data
})
}
/**
* 获取订单信息
*/
export function orderGet(data){
return request({
url:"order/getsave",
method: 'get',
data:data
})
}

11
api/user.js

@ -80,3 +80,14 @@ export function userChatCount(data){
data:data data:data
}) })
} }
/**
* 通过手机号获取token
* @param data
*/
export function tokenByPhone(data){
return request({
url:"user/gettokenbyphone",
method:'get',
data:data
})
}

7
pages/CardDetail/index.vue

@ -305,6 +305,7 @@ export default {
PayCardPolicy: '', PayCardPolicy: '',
address: {}, address: {},
petChecked: [], petChecked: [],
isPay : false
} }
}, },
onLoad(options) { onLoad(options) {
@ -334,6 +335,10 @@ export default {
api.error('请选择宠物'); api.error('请选择宠物');
return; return;
} }
if(this.isPay){
return;
}
this.isPay = true;
let petIds = this.petChecked.map((item) => { let petIds = this.petChecked.map((item) => {
return item.id; return item.id;
}).join(','); }).join(',');
@ -346,8 +351,10 @@ export default {
}).then(data => { }).then(data => {
api.payment(data.data).then(res => { api.payment(data.data).then(res => {
// api.success(''); // api.success('');
this.isPay = false;
uni.redirectTo({url: '/pages/Order/done?type=card'}); uni.redirectTo({url: '/pages/Order/done?type=card'});
}).catch(err => { }).catch(err => {
this.isPay = false;
api.error('支付失败') api.error('支付失败')
}) })
}); });

2
pages/Coupons/index.vue

@ -157,12 +157,14 @@
methods: { methods: {
getDrawList(){ getDrawList(){
drawList().then(data => { drawList().then(data => {
if(data.code === 200){
if(data.data.goodslists.length > 0){ if(data.data.goodslists.length > 0){
this.types = [ this.types = [
{title:'省点银子', value: 2}, {title:'省点银子', value: 2},
{title:'宝藏挖掘机', value: 1}, {title:'宝藏挖掘机', value: 1},
]; ];
} }
}
}); });
}, },
showCoupons(item){ showCoupons(item){

4
pages/FeedLog/index.vue

@ -348,7 +348,7 @@
onLoad(options) { onLoad(options) {
this.pet_id = options.pet_id; this.pet_id = options.pet_id;
this.type = options.type || 'detail'; this.type = options.type || 'detail';
this.feedLog(options.pet_id) this.getFeedLog(options.pet_id);
}, },
methods: { methods: {
redirtTo(url){ redirtTo(url){
@ -405,7 +405,7 @@
url:url url:url
}) })
}, },
feedLog(pet_id) { getFeedLog(pet_id) {
let that = this; let that = this;
feedLog(pet_id).then(data => { feedLog(pet_id).then(data => {
let feedlist = this.detail.feedlist; let feedlist = this.detail.feedlist;

26
pages/Help/index.vue

@ -25,7 +25,7 @@
:custom-style="{padding:'34rpx 0'}" :custom-style="{padding:'34rpx 0'}"
> >
<u-input <u-input
v-model="model.connect" v-model="model.phone"
inputAlign="right" inputAlign="right"
disabledColor="#ffffff" disabledColor="#ffffff"
placeholder="请填写帮填用户手机号" placeholder="请填写帮填用户手机号"
@ -49,6 +49,7 @@ import api from '@/utils/functions.js';
import HeaderNav from "@/components/HeaderNav/Index.vue"; import HeaderNav from "@/components/HeaderNav/Index.vue";
import MzButton from "@/components/MzButton/Index.vue"; import MzButton from "@/components/MzButton/Index.vue";
import {feedback} from "@/api/other"; import {feedback} from "@/api/other";
import {tokenByPhone} from "@/api/user";
export default { export default {
components: { components: {
@ -66,12 +67,10 @@ export default {
isTop: false, isTop: false,
fileList:[], fileList:[],
model:{ model:{
connect:'', phone:'',
remark:'',
file:[]
}, },
rules:{ rules:{
'connect': { 'phone': {
type: 'string', type: 'string',
required: true, required: true,
message: '请填写帮填用户手机号', message: '请填写帮填用户手机号',
@ -90,19 +89,14 @@ export default {
}, },
methods: { methods: {
submit(){ submit(){
feedback(this.model).then((res) => { tokenByPhone(this.model).then((res) => {
if(res.code === 200){ if(res.code === 200){
uni.$u.toast('反馈成功') uni.$u.toast('获取成功');
let user = uni.getStorageSync('user'); let user = uni.getStorageSync('token');
api.logout(true,false).then(() => {
uni.setStorageSync('workerToken',user); uni.setStorageSync('workerToken',user);
api.logout(); uni.setStorageSync('token',res.data.token);
uni.setStorageSync('token',res.data); });
this.model = {
connect:'',
remark:'',
file:[]
}
this.fileList = [];
}else{ }else{
uni.$u.toast(res.msg) uni.$u.toast(res.msg)
} }

4
pages/Index/components/OrderPage/index.vue

@ -213,8 +213,8 @@
let minDate = now.setMonth(now.getMonth()-6); let minDate = now.setMonth(now.getMonth()-6);
this.minDate = this.formatDate(minDate); this.minDate = this.formatDate(minDate);
this.start_time = ''; // this.start_time = '';
this.end_time = ''; // this.end_time = '';
console.log(this.minDate) console.log(this.minDate)
console.log(this.maxDate) console.log(this.maxDate)
}, },

13
pages/Index/components/UserPage/index.vue

@ -194,13 +194,13 @@
</view> </view>
<view class="user-title">我的奖品</view> <view class="user-title">我的奖品</view>
</view> </view>
<view class="user-button col-3"> <view class="user-button col-3" v-if="userInfo.is_waitstaff === 1">
<view class="img-box"> <view class="img-box">
<u-image width="48" height="48" class="img" :src="staticImage.more.about" @click="navTo('/pages/Help/list')" mode="aspectFit"></u-image> <u-image width="48" height="48" class="img" :src="staticImage.more.about" @click="navTo('/pages/Help/index')" mode="aspectFit"></u-image>
</view> </view>
<view class="user-title">进入帮填</view> <view class="user-title">进入帮填</view>
</view> </view>
<view class="user-button col-3"> <view class="user-button col-3" v-if="workerToken">
<view class="img-box"> <view class="img-box">
<u-image width="48" height="48" class="img" :src="staticImage.more.about" @click="clearWorkerUser" mode="aspectFit"></u-image> <u-image width="48" height="48" class="img" :src="staticImage.more.about" @click="clearWorkerUser" mode="aspectFit"></u-image>
</view> </view>
@ -280,12 +280,16 @@
pagePadding:100, pagePadding:100,
userInfo:{}, userInfo:{},
userExtends:{}, userExtends:{},
workerToken:{}
} }
}, },
methods: { methods: {
clearWorkerUser(){ clearWorkerUser(){
uni.removeStorageSync('workerUser'); let token = uni.getStorageSync('workerToken');
uni.removeStorageSync('workerToken');
uni.setStorageSync('token',token)
uni.showToast({title:'退出成功'}); uni.showToast({title:'退出成功'});
uni.reLaunch({url:'/pages/Index/index'})
}, },
openPrivacyContract() { openPrivacyContract() {
uni.openPrivacyContract({}); uni.openPrivacyContract({});
@ -323,6 +327,7 @@
} }
}, },
showUserInfo(){ showUserInfo(){
this.workerToken = uni.getStorageSync('workerToken');
userDetail().then(res => { userDetail().then(res => {
this.$store.commit('userInfo', UserCache.setAndReturn(res.data)); this.$store.commit('userInfo', UserCache.setAndReturn(res.data));
}) })

3
pages/Index/index.vue

@ -101,12 +101,15 @@
}, },
// store. // store.
showUserInfo(){ showUserInfo(){
let token = uni.getStorageSync('token');
if(token){
userDetail().then(res => { userDetail().then(res => {
this.$store.commit('userInfo', UserCache.setAndReturn(res.data)); this.$store.commit('userInfo', UserCache.setAndReturn(res.data));
}) })
userExtends().then(res => { userExtends().then(res => {
this.$store.commit('userExtends', UserCache.extSetAndReturn(res.data)); this.$store.commit('userExtends', UserCache.extSetAndReturn(res.data));
}) })
}
} }
}, },
onReachBottom() { onReachBottom() {

6
pages/OrderConfirm/end.vue

@ -1414,8 +1414,8 @@ export default {
sick:{option:'',remark:'',upload:[]}, sick:{option:'',remark:'',upload:[]},
excrement:{option:'',remark:'',upload:[]}, excrement:{option:'',remark:'',upload:[]},
other :{option:'',remark:'',upload:[]}, other :{option:'',remark:'',upload:[]},
food_bowl :{option:'',remark:'',upload:[]}, food_bowl :{value:'',remark:'',upload:[]},
basin :{option:'',remark:'',upload:[]}, basin :{value:'',remark:'',upload:[]},
staple_food :{option:'',type_option:'',remark:'',upload:[]}, staple_food :{option:'',type_option:'',remark:'',upload:[]},
water :{option:'',remark:'',upload:[]}, water :{option:'',remark:'',upload:[]},
snacks :{option:'',remark:'',upload:[]}, snacks :{option:'',remark:'',upload:[]},
@ -1604,7 +1604,7 @@ export default {
orderEnd(this.model).then((res) => { orderEnd(this.model).then((res) => {
if (res.code === 200) { if (res.code === 200) {
api.success('保存成功').then(() => { api.success('保存成功').then(() => {
// uni.navigateBack(); uni.navigateBack();
}) })
} else { } else {
uni.$u.toast(res.msg) uni.$u.toast(res.msg)

430
pages/OrderDetail/index.vue

File diff suppressed because it is too large Load Diff

102
pages/OrderPage/index.vue

@ -138,7 +138,7 @@
<image mode="heightFix" class="img" :src="staticImage.selectPet"/> <image mode="heightFix" class="img" :src="staticImage.selectPet"/>
</view> </view>
<view class="order-item pet-page-item row"> <view class="order-item pet-page-item row">
<PetPage class="pet-page" :showCancel="true" type="lists" @change="selectPet" @del="delPet"></PetPage> <PetPage ref="petPage" class="pet-page" :showCancel="true" type="lists" @change="selectPet" @del="delPet"></PetPage>
</view> </view>
@ -222,7 +222,7 @@
</view> </view>
</view> </view>
</view> </view>
<view class=""> <view class="" v-if="!is_worker">
<MzButton <MzButton
title="立即下单" title="立即下单"
button-color="#4DC3B8" button-color="#4DC3B8"
@ -232,6 +232,16 @@
> >
</MzButton> </MzButton>
</view> </view>
<view class="" v-else>
<MzButton
title="保存订单"
button-color="#4DC3B8"
font-color="#FFFFFF"
button-width="200rpx"
@click="setCacheOrder"
>
</MzButton>
</view>
</view> </view>
<uv-calendar ref="calendar" mode="multiple" title="选择服务日期" color="#4DC3B8" round="40rpx"> <uv-calendar ref="calendar" mode="multiple" title="选择服务日期" color="#4DC3B8" round="40rpx">
<template #footer> <template #footer>
@ -375,7 +385,7 @@
import {cardDetail} from "@/api/card"; import {cardDetail} from "@/api/card";
import {getAddressList} from "@/api/address"; import {getAddressList} from "@/api/address";
import image from "@/config/image"; import image from "@/config/image";
import {createOrderPrice, getOrderPrice, getStoreService} from "@/api/order"; import {createOrderPrice, getOrderPrice, getStoreService, orderGet, orderSave} from "@/api/order";
import pet from "@/pages/Pet/index.vue"; import pet from "@/pages/Pet/index.vue";
import {getConfig} from "@/api/other"; import {getConfig} from "@/api/other";
import log from "@/utils/log"; import log from "@/utils/log";
@ -477,22 +487,73 @@
isPay:false, isPay:false,
type:1, type:1,
add_time:0, add_time:0,
is_worker:false,
sign:'',
} }
}, },
onLoad(options) { onLoad(options) {
this.id = options.id; this.id = options.id;
this.type = options.type || 1; this.type = options.type || 1;
this.sign = options.sign || '';
if(this.sign!=='')this.getCacheOrder();
let workerToken = uni.getStorageSync('workerToken');
if(workerToken)this.is_worker = true;
}, },
updated() { updated() {
}, },
onShow(){ onShow(){
if(!this.isPay){ if(!this.isPay && this.sign === ''){
this.getDefaultAddress(); this.getDefaultAddress();
this.getUserCoupons(); this.getUserCoupons();
} }
},
onShareAppMessage() {
return {
title:'预约服务',
path:'/pages/OrderPage/index?sign='+this.sign,
}
}, },
methods: { methods: {
setCacheOrder(){
let data = {};
data.type = this.type;
data.address = this.address;
data.timeList = this.timeList;
data.addServiceList = this.addServiceList;
data.addServiceChecked = this.addServiceChecked;
data.petChecked = this.petChecked;
data.coupons = this.coupons;
data.add_time = this.add_time;
data.basicServiceList = this.basicServiceList;
data.basicServiceChecked = this.basicServiceChecked;
orderSave({sign:this.sign,data:JSON.stringify(data)}).then((res) => {
this.sign = res.data.sign;
});
log('orderData',data);
api.success('保存成功')
},
getCacheOrder(){
let data = {};
log('orderData',data);
orderGet({sign:this.sign}).then(res => {
data = JSON.parse(res.data.data);
this.type = data.type;
this.address = data.address;
this.timeList = data.timeList;
this.petChecked = data.petChecked;
this.$refs.petPage.petCheckList = data.petChecked;
this.addServiceList = data.addServiceList;
this.addServiceChecked = data.addServiceChecked;
this.coupons = data.coupons;
this.add_time = data.add_time;
this.basicServiceList = data.basicServiceList;
this.basicServiceChecked = data.basicServiceChecked;
this.sign = '';
this.checkOrderData();
});
},
addTimeConfirm(e){ addTimeConfirm(e){
this.add_time = e.value[0].value; this.add_time = e.value[0].value;
}, },
@ -500,6 +561,9 @@
this.addServiceList[e].checked = !this.addServiceList[e].checked; this.addServiceList[e].checked = !this.addServiceList[e].checked;
}, },
orderPay(){ orderPay(){
if(this.isPay){
return;
}
uni.showLoading('加载中'); uni.showLoading('加载中');
if( if(
this.address this.address
@ -517,14 +581,21 @@
order_type:this.type, order_type:this.type,
address_id: this.address.id, address_id: this.address.id,
do_date: this.timeList.map(res => [res.date,res.time]), do_date: this.timeList.map(res => [res.date,res.time]),
services: this.addServiceChecked.map(res => res.id).join(','), services: this.addServiceChecked.map(res => {
return {
id:res.id,
number:res.number
}
}),
basic_service:this.basicServiceChecked, basic_service:this.basicServiceChecked,
pet_ids: this.petChecked.map(res => res.id).join(','), pet_ids: this.petChecked.map(res => res.id).join(','),
store_id:this.addServiceList[0].store_id, store_id:this.addServiceList[0].store_id,
user_coupon_id: coupons || 0 user_coupon_id: coupons || 0
}).then(res => { }).then(res => {
console.log(res) console.log(res)
if(this.price.price>0){
api.payment(res.data).then(res => { api.payment(res.data).then(res => {
this.isPay = false;
uni.redirectTo({url:'/pages/Order/done?type=order'}); uni.redirectTo({url:'/pages/Order/done?type=order'});
uni.hideLoading(); uni.hideLoading();
}).catch(err => { }).catch(err => {
@ -532,6 +603,10 @@
api.error('支付失败'); api.error('支付失败');
uni.hideLoading(); uni.hideLoading();
}); });
}else{
uni.redirectTo({url:'/pages/Order/done?type=order'});
uni.hideLoading();
}
}); });
}else{ }else{
uni.hideLoading(); uni.hideLoading();
@ -560,19 +635,28 @@
&&this.petChecked.length>0 &&this.petChecked.length>0
&&this.basicServiceChecked!=='' &&this.basicServiceChecked!==''
){ ){
console.log(this.basicServiceChecked) let coupons = this.coupons.map(item => {
return item.id;
}).join(',');
getOrderPrice({ getOrderPrice({
order_type:this.type, order_type:this.type,
address_id: this.address.id, address_id: this.address.id,
do_date: this.timeList.map(res => [res.date,res.time]), do_date: this.timeList.map(res => [res.date,res.time]),
services: this.addServiceChecked.map(res => res.id).join(','), services: this.addServiceChecked.map(res => {
return {
id:res.id,
number:res.number
}
}),
basic_service:this.basicServiceChecked, basic_service:this.basicServiceChecked,
pet_ids: this.petChecked.map(res => res.id).join(','), pet_ids: this.petChecked.map(res => res.id).join(','),
store_id:this.addServiceList[0].store_id, store_id:this.addServiceList[0].store_id,
user_coupon_id:this.coupons.id || 0 user_coupon_id:coupons || 0
}).then(res => { }).then(res => {
console.log(res) console.log('res',res)
this.price = res.data; this.price = res.data;
}).catch(err => {
log('err',err)
}); });
} }
}, },

4
pages/UserCoupons/index.vue

@ -37,7 +37,7 @@
</view> </view>
<view class="coupons-bottom col-12 row"> <view class="coupons-bottom col-12 row">
<view class="coupons-rule row col" @click="showCoupons(item)">查看使用规则 <u-icon class="arrow-right" size="24rpx" color="#999999" name="arrow-right"></u-icon></view> <view class="coupons-rule row col" @click="showCoupons(item)">查看使用规则 <u-icon class="arrow-right" size="24rpx" color="#999999" name="arrow-right"></u-icon></view>
<view class="coupons-button"> <view class="coupons-button" v-if="type==='select'">
<MzButton <MzButton
:title="couponType===1?(item.checked?'取消选择':'选择'):'立即使用'" :title="couponType===1?(item.checked?'取消选择':'选择'):'立即使用'"
@click="couponType===1?item.checked = !item.checked:clickCoupons(item)" @click="couponType===1?item.checked = !item.checked:clickCoupons(item)"
@ -62,7 +62,7 @@
line-color="#ACB4B6" line-color="#ACB4B6"
marginBottom="30" marginTop="30" @loadmore="getCouponsList(++this.page)"/> marginBottom="30" marginTop="30" @loadmore="getCouponsList(++this.page)"/>
</view> </view>
<view class="footer-menu row" v-if="couponType===1"> <view class="footer-menu row" v-if="couponType===1 && type === 'select'">
<view class="footer-button col-12"> <view class="footer-button col-12">
<MzButton <MzButton
title="确认" title="确认"

18
utils/functions.js

@ -327,21 +327,33 @@ const api = {
}); });
}) })
}, },
logout:() => { logout:(reLaunch = true,confirm = true) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if(confirm){
api.confirm('是否退出登录').then(res => { api.confirm('是否退出登录').then(res => {
api.doLogout(reLaunch)
resolve();
})
}else{
api.doLogout(reLaunch);
resolve();
}
})
},
doLogout:(reLaunch = true)=>{
uni.showLoading('退出中'); uni.showLoading('退出中');
uni.clearStorageSync(); uni.clearStorageSync();
store.commit('userInfo',{}); store.commit('userInfo',{});
store.commit('userExtends',{}); store.commit('userExtends',{});
api.uniSysInfo().then(() => { api.uniSysInfo().then(() => {
if(reLaunch){
uni.reLaunch({url:'/pages/Index/index'}); uni.reLaunch({url:'/pages/Index/index'});
}
uni.hideLoading(); uni.hideLoading();
}).catch(err => { }).catch(err => {
uni.hideLoading(); uni.hideLoading();
}) })
})
})
}, },
navTo:(url,token = false) => { navTo:(url,token = false) => {
if (token) { if (token) {

45
utils/requestOther.js

@ -0,0 +1,45 @@
import functions from '@/utils/functions.js'
import {host} from "@/config/host";
const service = (params) => {
return new Promise((relove, reject) => {
let token=uni.getStorageSync('token')
let user=uni.getStorageSync('user')
if (!/^http/.test(params.url)){
params.url = `${host}/${params.url}`.replace(/(?<!:)\/{2,}/, '/')
}
uni.request({
url: params.url,
data: params.data,
method: params.method,
dataType: "json",
header: {
"content-type": "application/json;charset=utf-8",
"Authorization":"Bearer "+ token
}
}).then(res => {
if (res.statusCode === 200) {
let data = res.data;
switch (data.code) {
case 1001:
uni.setStorageSync('token',data.data);
service(params);
break;
case 1002:
// todo 让用户重新登录
reject(data);
break;
default:
relove(data);
}
} else {
functions.error('连接服务器失败')
}
})
})
}
export default service;
Loading…
Cancel
Save