Browse Source

feat: 接口对接;

pull/2/head
fox 1 month ago
parent
commit
684c4f5190
8 changed files with 150 additions and 79 deletions
  1. +1
    -1
      api/model/product.js
  2. +28
    -0
      api/model/shop.js
  3. +1
    -7
      components/base/tabbar.vue
  4. +7
    -0
      components/order/orderCard.vue
  5. +4
    -1
      pages.json
  6. +91
    -6
      pages_order/mine/cooperation.vue
  7. +1
    -1
      pages_order/mine/voucher.vue
  8. +17
    -63
      pages_order/order/createOrder.vue

+ 1
- 1
api/model/product.js View File

@ -33,7 +33,7 @@ const api = {
/** /**
* 获取优惠券信息 * 获取优惠券信息
*/ */
queryShopList: {
queryVoucherShopList: {
url: '/vouchers/queryShopList', url: '/vouchers/queryShopList',
method: 'GET', method: 'GET',
}, },


+ 28
- 0
api/model/shop.js View File

@ -2,6 +2,24 @@
// 商家相关接口 // 商家相关接口
const api = { const api = {
/**
* 查询商家详情
*/
queryShopList: {
url: '/shop/queryShopList',
method: 'GET',
auth : true,
showLoading : true,
},
/**
* 查询商家详情
*/
queryShopById: {
url: '/shop/queryShopById',
method: 'GET',
auth : true,
showLoading : true,
},
/** /**
* 新增商家信息 * 新增商家信息
*/ */
@ -12,6 +30,16 @@ const api = {
auth : true, auth : true,
showLoading : true, showLoading : true,
}, },
/**
* 修改商家信息
*/
updateShop: {
url: '/shop/updateShop',
method: 'POST',
limit : 500,
auth : true,
showLoading : true,
},
} }
export default api export default api

+ 1
- 7
components/base/tabbar.vue View File

@ -1,7 +1,6 @@
<template> <template>
<view class="tabbar-box"> <view class="tabbar-box">
<view class="tabbar"> <view class="tabbar">
<!-- v-if="!item.isNotShop || !userShop" -->
<view <view
:class="{ 'tabbar-active' : select == item.key}" :class="{ 'tabbar-active' : select == item.key}"
v-for="(item, index) in list" :key="index" v-for="(item, index) in list" :key="index"
@ -21,15 +20,10 @@
</template> </template>
<script> <script>
import {
mapGetters
} from 'vuex'
export default { export default {
name: "tabbar", name: "tabbar",
props: ['select'], props: ['select'],
computed: {
...mapGetters(['userShop']),
},
data() { data() {
return { return {
list: [{ list: [{


+ 7
- 0
components/order/orderCard.vue View File

@ -78,6 +78,13 @@
}) })
}, },
onPay() { onPay() {
this.$store.commit('setPayOrderProduct', [
this.data.massageItem
])
this.$utils.navigateTo(`/pages_order/order/createOrder?id=${this.data.id}`)
return
// todo // todo
this.$api('payOrder', { this.$api('payOrder', {
orderId : this.data.id, orderId : this.data.id,


+ 4
- 1
pages.json View File

@ -92,7 +92,10 @@
"path": "mine/pointsRecord" "path": "mine/pointsRecord"
}, },
{ {
"path": "mine/cooperation"
"path": "mine/cooperation",
"style": {
"enablePullDownRefresh": true
}
}, },
{ {
"path": "mine/verifyRecord" "path": "mine/verifyRecord"


+ 91
- 6
pages_order/mine/cooperation.vue View File

@ -3,6 +3,11 @@
<!-- 导航栏 --> <!-- 导航栏 -->
<navbar title="商家合作" leftClick @leftClick="$utils.navigateBack" color="#fff" /> <navbar title="商家合作" leftClick @leftClick="$utils.navigateBack" color="#fff" />
<view v-if="['0', '2'].includes(status) && statusDesc" class="flex tips">
<uv-icon name="info-circle" color="#86A941" size="28rpx"></uv-icon>
<text style="margin-left: 3rpx;">{{ statusDesc }}</text>
</view>
<view class="content"> <view class="content">
<view class="form"> <view class="form">
<view class="form-title">门头照片</view> <view class="form-title">门头照片</view>
@ -83,7 +88,7 @@
</uv-form> </uv-form>
</view> </view>
</view> </view>
<view class="tools">
<view class="tools" v-if="status != '1'">
<button plain class="btn btn-submit" @click="onSubmit">提交</button> <button plain class="btn btn-submit" @click="onSubmit">提交</button>
</view> </view>
</view> </view>
@ -91,11 +96,13 @@
</template> </template>
<script> <script>
import Position from '@/utils/position.js'
import { mapState } from 'vuex'
import Position from '@/utils/position.js'
import formInput from '../components/formInput.vue'
import formUpload from '../components/formUpload.vue'
import formTextarea from '../components/formTextarea.vue'
import formInput from '../components/formInput.vue'
import formUpload from '../components/formUpload.vue'
import formTextarea from '../components/formTextarea.vue'
export default { export default {
components: { components: {
@ -105,6 +112,9 @@ export default {
}, },
data() { data() {
return { return {
id: null,
status: null,
statusDesc: null,
form: { form: {
image: null, image: null,
shop: null, shop: null,
@ -149,6 +159,15 @@ export default {
}, },
} }
}, },
computed: {
...mapState(['userInfo']),
},
onLoad() {
this.initData()
},
onPullDownRefresh() {
this.updateStatus()
},
methods: { methods: {
// //
selectAddr() { selectAddr() {
@ -172,6 +191,62 @@ export default {
} }
this.form.area = '' // this.form.area = '' //
}, },
async initData() {
try {
const shopList = (await this.$fetch('queryShopList', { userId: this.userInfo.id }))?.records
if (!shopList.length) {
return
}
const {
id,
status,
status_dictText,
image,
shop,
name,
phone,
area,
latitude,
longitude,
address,
} = shopList[0]
this.form = {
image,
shop,
name,
phone,
area,
latitude,
longitude,
address,
}
this.id = id
this.status = status
this.statusDesc = status_dictText
} catch (err) {
}
},
async updateStatus() {
if (!this.id) {
return
}
try {
const { status, status_dictText } = await this.$fetch('queryShopById', { id: this.id })
this.status = status
this.statusDesc = status_dictText
} catch (err) {
}
},
async onSubmit() { async onSubmit() {
try { try {
@ -198,8 +273,10 @@ export default {
longitude, longitude,
address, address,
} }
let api = this.id ? 'updateShop' : 'addShop'
await this.$fetch('addShop', params)
await this.$fetch(api, params)
uni.showToast({ uni.showToast({
title: '提交成功', title: '提交成功',
@ -227,6 +304,14 @@ export default {
} }
} }
.tips {
padding: 5rpx 0;
font-weight: bold;
font-size: 28rpx;
color: $uni-color;
background-color: rgba($color: #D8FF8F, $alpha: 0.3);
}
.content { .content {
padding: 28rpx 30rpx; padding: 28rpx 30rpx;
} }


+ 1
- 1
pages_order/mine/voucher.vue View File

@ -59,7 +59,7 @@
const TAB_AND_API_FIELDS_MAPPING = { const TAB_AND_API_FIELDS_MAPPING = {
0: 'queryVouchersList', 0: 'queryVouchersList',
1: 'queryShopList',
1: 'queryVoucherShopList',
} }
export default { export default {


+ 17
- 63
pages_order/order/createOrder.vue View File

@ -83,6 +83,7 @@
}, },
data() { data() {
return { return {
orderId: null,
selectedCoupon: [], selectedCoupon: [],
num: 1, num: 1,
coupon: {}, coupon: {},
@ -105,8 +106,9 @@
}, },
...mapState(['userInfo', 'payOrderProduct']), ...mapState(['userInfo', 'payOrderProduct']),
}, },
onLoad(args) {
onLoad({ id }) {
this.$store.commit('getUserInfo') this.$store.commit('getUserInfo')
this.orderId = id
}, },
onShow() { onShow() {
this.getCouponList() this.getCouponList()
@ -128,24 +130,27 @@
this.selectedCoupon = [1] this.selectedCoupon = [1]
}, },
async fetchCreateOrder() {
async fetchPayOrder() {
// todo: check // todo: check
let params = { let params = {
itemId: this.payOrderProduct[0].id,
amount: this.totalPrice,
payType : this.payMethod, payType : this.payMethod,
// id: this.payOrderProduct[0].id, // id: this.payOrderProduct[0].id,
// num: this.payOrderProduct[0].num, // num: this.payOrderProduct[0].num,
// memberNum : 1, // memberNum : 1,
} }
// todo: check
// if (this.coupon.id) {
// data.couponId = this.coupon.id
// }
const res = await this.$fetch('createOrder', params, false)
let api = 'createOrder'
if (this.orderId) { //
params.orderId = this.orderId
api = 'payOrder'
} else { //
params.itemId = this.payOrderProduct[0].id
params.amount = this.totalPrice
}
const res = await this.$fetch(api, params, false)
return res return res
}, },
@ -153,7 +158,7 @@
try { try {
const res = await this.fetchCreateOrder()
const res = await this.fetchPayOrder()
if (!res.success) { if (!res.success) {
return return
@ -162,6 +167,7 @@
if (this.payMethod == 1) { // if (this.payMethod == 1) { //
} else { // } else { //
console.log('--发起支付接口回调', res)
await uni.requestPaymentWxPay(res) await uni.requestPaymentWxPay(res)
} }
@ -174,59 +180,7 @@
url: '/pages/index/order' url: '/pages/index/order'
}) })
} catch (err) { } catch (err) {
} }
return
let data = {
'massageItem.id': this.payOrderProduct[0].id,
// todo: check
amount: this.totalPrice,
// num: this.payOrderProduct[0].num,
// id: this.payOrderProduct[0].id,
// payType : this.payMethod,
// memberNum : 1,
}
// todo: check
// if (this.coupon.id) {
// data.couponId = this.coupon.id
// }
this.$api('createOrder', data, res => {
if (res.code == 200) {
if(this.payMethod == 1){
uni.showToast({
title: '下单成功',
icon: 'none'
})
this.paySuccess(res)
return
}
uni.requestPaymentWxPay(res).then(e => {
uni.showToast({
title: '下单成功',
icon: 'none'
})
this.paySuccess(res)
}).catch(n => {
setTimeout(uni.redirectTo, 700, {
url: '/pages/index/order'
})
})
}
})
},
paySuccess(res){
setTimeout(uni.redirectTo, 700, {
url: '/pages/index/order'
})
}, },
} }
} }


Loading…
Cancel
Save