Browse Source

上传

master
前端-胡立永 7 months ago
parent
commit
f607982274
4 changed files with 118 additions and 21 deletions
  1. +18
    -0
      api/api.js
  2. +3
    -2
      api/http.js
  3. +43
    -16
      pages/index/order.vue
  4. +54
    -3
      store/store.js

+ 18
- 0
api/api.js View File

@ -8,6 +8,24 @@ const config = {
// }, // },
getConfig : {url : '/api/getConfig', method : 'GET', limit : 500}, getConfig : {url : '/api/getConfig', method : 'GET', limit : 500},
// 微信登录接口
wxLogin: {
url: '/login/login',
method: 'POST',
limit : 500,
showLoading : true,
},
// 修改个人信息接口
updateInfo: {
url: '/info/updateInfo',
method: 'POST',
auth: true,
limit : 500,
showLoading : true,
},
} }


+ 3
- 2
api/http.js View File

@ -25,11 +25,12 @@ function http(uri, data, callback, method = 'GET', showLoading, title) {
} }
if(res.statusCode == 401 || if(res.statusCode == 401 ||
res.data.message == '操作失败,token非法无效!'){
res.data.message == '操作失败,token非法无效!' ||
res.data.message == '操作失败,用户不存在!'){
uni.removeStorageSync('token') uni.removeStorageSync('token')
console.error('登录过期'); console.error('登录过期');
uni.navigateTo({ uni.navigateTo({
url: '/pages/auth/login'
url: '/pages_order/auth/wxLogin'
}) })
} }


+ 43
- 16
pages/index/order.vue View File

@ -14,7 +14,7 @@
<view v-if="orderList.length > 0" class="list"> <view v-if="orderList.length > 0" class="list">
<view class="item" <view class="item"
v-for="(item, index) in orderList"
v-for="(item, index) in orderList.records"
@click="toOrderDetail(item.id)" @click="toOrderDetail(item.id)"
:key="index"> :key="index">
@ -112,30 +112,57 @@
pageNo: 1, pageNo: 1,
pageSize: 10 pageSize: 10
}, },
orderList: [
{
money : 99.99,
address : '广东省广州市越秀区城南故事C3栋2802',
name : '李**',
phone : '150*****091',
unit : '120*40*75【桌子尺寸】',
image : 'https://img95.699pic.com/photo/50058/1378.jpg_wh860.jpg',
state_dictText : '已完成',
}
], //
// orderList: [
// {
// money : 99.99,
// address : '广广C32802',
// name : '**',
// phone : '150*****091',
// unit : '120*40*75',
// image : 'https://img95.699pic.com/photo/50058/1378.jpg_wh860.jpg',
// state_dictText : '',
// }
// ], //
orderList : {
records : [],
total : 0,
},
state : -1,
} }
}, },
computed : {
onShow() {
this.orderPage()
},
//
onReachBottom() {
if(this.queryParams.pageSize < this.orderList.total){
this.queryParams.pageSize += 10
this.orderPage()
}
}, },
methods: { methods: {
orderPage(){
let queryParams = {
...this.queryParams,
}
if(this.state != -1){
queryParams.state = this.state
}
this.$api('orderPage', queryParams, res => {
if(res.code == 200){
this.orderList = res.result
}
})
},
//tab //tab
clickTabs(index) { clickTabs(index) {
if (index == 0) { if (index == 0) {
this.queryParams.state = -1;
this.state = -1;
} else { } else {
this.queryParams.state = index - 1;
this.state = index - 1;
} }
this.getOrderList()
this.queryParams.pageSize = 10
this.orderPage()
}, },
// //
toOrderDetail(id) { toOrderDetail(id) {


+ 54
- 3
store/store.js View File

@ -9,7 +9,8 @@ import api from '@/api/api.js'
const store = new Vuex.Store({ const store = new Vuex.Store({
state: { state: {
configList: [], //配置列表 configList: [], //配置列表
shop : false
shop : false,
userInfo : {}, //用户信息
}, },
getters: { getters: {
// 角色 true为水洗店 false为酒店 // 角色 true为水洗店 false为酒店
@ -20,9 +21,59 @@ const store = new Vuex.Store({
mutations: { mutations: {
// 初始化配置 // 初始化配置
initConfig(state){ initConfig(state){
api('getConfig', res => {
// api('getConfig', res => {
// if(res.code == 200){
// state.configList = res.result
// }
// })
let config = ['getPrivacyPolicy', 'getUserAgreement']
config.forEach(k => {
api(k, res => {
if (res.code == 200) {
state.configList[k] = res.result
}
})
})
},
login(state){
uni.showLoading({
title: '登录中...'
})
uni.login({
success(res) {
if(res.errMsg != "login:ok"){
return
}
api('wxLogin', {
code : res.code
}, res => {
uni.hideLoading()
if(res.code != 200){
return
}
state.userInfo = res.result.userInfo
uni.setStorageSync('token', res.result.token)
if(!state.userInfo.nickName || !state.userInfo.headImage){
uni.navigateTo({
url: '/pages_order/auth/wxUserInfo'
})
}else{
uni.navigateBack(-1)
}
})
}
})
},
getUserInfo(state){
api('infoGetInfo', res => {
if(res.code == 200){ if(res.code == 200){
state.configList = res.result
state.userInfo = res.result
} }
}) })
}, },


Loading…
Cancel
Save