Browse Source

上传

master
前端-胡立永 3 months ago
parent
commit
a2298b8169
7 changed files with 91 additions and 38 deletions
  1. +19
    -32
      api/api.js
  2. +2
    -3
      api/http.js
  3. +40
    -0
      api/model/order.js
  4. +1
    -0
      pages_order/components/product/submitUnitSelect.vue
  5. +1
    -1
      pages_order/order/order.vue
  6. +14
    -1
      pages_order/order/orderDetail.vue
  7. +14
    -1
      utils/utils.js

+ 19
- 32
api/api.js View File

@ -1,4 +1,5 @@
import http from './http.js' import http from './http.js'
import utils from '../utils/utils.js'
let limit = {} let limit = {}
@ -304,38 +305,13 @@ const config = {
showLoading : true, showLoading : true,
}, },
// 商城-立即兑换商品
createPointsOrder : {
url: '/city/createPointsOrder',
method: 'POST',
auth : true,
showLoading : true,
limit : 1000,
},
// 商城-立即兑换商品,微信支付购买商品
createOrder : {
url: '/city/createOrder',
method: 'POST',
auth : true,
showLoading : true,
limit : 1000,
},
// 商城-订单列表
getOrderList : {
url: '/city/getOrderList',
method: 'POST',
auth : true,
},
// 商城-订单详情
getOrderDetail : {
url: '/city/getOrderDetail',
method: 'POST',
auth : true,
},
} }
const models = ['order']
models.forEach(key => {
addApiModel(require(`./model/${key}.js`).default, key)
})
export function api(key, data, callback, loadingTitle) { export function api(key, data, callback, loadingTitle) {
let req = config[key] let req = config[key]
@ -367,9 +343,7 @@ export function api(key, data, callback, loadingTitle) {
//必须登录 //必须登录
if (req.auth) { if (req.auth) {
if (!uni.getStorageSync('token')) { if (!uni.getStorageSync('token')) {
uni.navigateTo({
url: '/pages_order/auth/wxLogin'
})
utils.toLogin()
console.error('需要登录') console.error('需要登录')
return return
} }
@ -404,4 +378,17 @@ export function api(key, data, callback, loadingTitle) {
function addApiModel(model, key){
for(let k in model){
if(config[`${k}`]){
console.error(`重名api------model=${key},key=${k}`);
continue
}
config[`${k}`] = model[k]
// config[`${key}_${k}`] = model[k]
}
}
export default api export default api

+ 2
- 3
api/http.js View File

@ -1,5 +1,6 @@
import Vue from 'vue' import Vue from 'vue'
import utils from '../utils/utils.js'
function http(uri, data, callback, method = 'GET', showLoading, title) { function http(uri, data, callback, method = 'GET', showLoading, title) {
@ -29,9 +30,7 @@ function http(uri, data, callback, method = 'GET', showLoading, title) {
res.data.message == '操作失败,用户不存在!'){ res.data.message == '操作失败,用户不存在!'){
uni.removeStorageSync('token') uni.removeStorageSync('token')
console.error('登录过期'); console.error('登录过期');
uni.navigateTo({
url: '/pages_order/auth/wxLogin'
})
utils.toLogin()
} }
if(res.statusCode == 200 && res.data.code != 200){ if(res.statusCode == 200 && res.data.code != 200){


+ 40
- 0
api/model/order.js View File

@ -0,0 +1,40 @@
// 商城接口
const api = {
// 商城-立即兑换商品
createPointsOrder : {
url: '/order/createPointsOrder',
method: 'POST',
auth : true,
showLoading : true,
limit : 1000,
},
// 商城-立即兑换商品,微信支付购买商品
createOrder : {
url: '/order/createOrder',
method: 'POST',
auth : true,
showLoading : true,
limit : 1000,
},
// 商城-订单列表
getOrderList : {
url: '/order/getOrderList',
method: 'POST',
auth : true,
},
// 商城-订单详情
getOrderDetail : {
url: '/order/getOrderDetail',
method: 'POST',
auth : true,
},
}
export default api

+ 1
- 0
pages_order/components/product/submitUnitSelect.vue View File

@ -204,6 +204,7 @@
} }
this.$api('createPointsOrder', data, res => { this.$api('createPointsOrder', data, res => {
// this.$api('order_createPointsOrder', data, res => {
if(res.code == 200){ if(res.code == 200){
uni.redirectTo({ uni.redirectTo({


+ 1
- 1
pages_order/order/order.vue View File

@ -11,7 +11,7 @@
lineColor="#FD5100" lineColor="#FD5100"
lineHeight="8rpx" lineHeight="8rpx"
lineWidth="50rpx" lineWidth="50rpx"
:scrollable="true"
:scrollable="false"
@click="clickTabs"></uv-tabs> @click="clickTabs"></uv-tabs>
<view class="list"> <view class="list">


+ 14
- 1
pages_order/order/orderDetail.vue View File

@ -241,10 +241,23 @@
createTime : '2024-01-18 15:39', createTime : '2024-01-18 15:39',
projectName : '桌布租赁' projectName : '桌布租赁'
}, },
id : 0,
} }
}, },
onLoad(args) {
this.id = args.id
},
onShow() {
this.getDetail()
},
methods: { methods: {
getDetail(){
this.$api('getOrderDetail', {
id : this.id
}, res => {
})
},
} }
} }
</script> </script>


+ 14
- 1
utils/utils.js View File

@ -178,6 +178,18 @@ export function navigateBack(num = -1){
export function redirectTo(...args){ export function redirectTo(...args){
uni.redirectTo(params(...args)) uni.redirectTo(params(...args))
} }
export const toLogin = function(){
let time = 0
return () => {
if(new Date().getTime() - time < 1000){
return
}
time = new Date().getTime()
uni.navigateTo({
url: '/pages_order/auth/wxLogin'
})
}
}()
export default { export default {
toArray, toArray,
@ -192,5 +204,6 @@ export default {
navigateBack, navigateBack,
redirectTo, redirectTo,
copyText, copyText,
stringFormatHtml
stringFormatHtml,
toLogin
} }

Loading…
Cancel
Save