#2 feat: 接口对接;

Merged
Fox merged 2 commits from fox into master 1 month ago
  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. +6
    -3
      pages/index/center.vue
  7. +94
    -6
      pages_order/mine/cooperation.vue
  8. +1
    -1
      pages_order/mine/voucher.vue
  9. +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',
method: 'GET',
},


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

@ -2,6 +2,24 @@
// 商家相关接口
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,
showLoading : true,
},
/**
* 修改商家信息
*/
updateShop: {
url: '/shop/updateShop',
method: 'POST',
limit : 500,
auth : true,
showLoading : true,
},
}
export default api

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

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


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

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


+ 4
- 1
pages.json View File

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


+ 6
- 3
pages/index/center.vue View File

@ -2,7 +2,7 @@
<view class="page">
<view class="flex flex-column header">
<view class="user">
<view class="flex flex-column user">
<image class="user-avatar" :src="userInfo.headImage" mode="aspectFill"></image>
<view class="user-name">{{ userInfo.nickName }}</view>
</view>
@ -86,7 +86,7 @@
</view>
<view class="card fun-common">
<view v-if="userInfo.is_merchants" class="fun-header">
<view v-if="isMerchants" class="fun-header">
<cardTitle>常用功能</cardTitle>
</view>
<view class="fun-content fun-common-content">
@ -126,7 +126,7 @@
</view>
</view>
<view v-if="userInfo.is_merchants" class="card fun-merchant">
<view v-if="isMerchants" class="card fun-merchant">
<view class="fun-header">
<cardTitle>商家功能</cardTitle>
</view>
@ -168,6 +168,9 @@
computed: {
...mapGetters(['role']),
...mapState(['userInfo', 'riceInfo']),
isMerchants() {
return this.userInfo.isMerchants === '1'
},
},
data() {
return {


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

@ -3,6 +3,11 @@
<!-- 导航栏 -->
<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="form">
<view class="form-title">门头照片</view>
@ -83,7 +88,7 @@
</uv-form>
</view>
</view>
<view class="tools">
<view class="tools" v-if="status != '1'">
<button plain class="btn btn-submit" @click="onSubmit">提交</button>
</view>
</view>
@ -91,11 +96,13 @@
</template>
<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 {
components: {
@ -105,6 +112,9 @@ export default {
},
data() {
return {
id: null,
status: null,
statusDesc: null,
form: {
image: null,
shop: null,
@ -149,6 +159,15 @@ export default {
},
}
},
computed: {
...mapState(['userInfo']),
},
onLoad() {
this.initData()
},
onPullDownRefresh() {
this.updateStatus()
},
methods: {
//
selectAddr() {
@ -172,6 +191,65 @@ export default {
}
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,
remark,
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 == '2' ? `${status_dictText}${remark}` : status_dictText
} catch (err) {
}
},
async updateStatus() {
if (!this.id) {
return
}
try {
const { status, status_dictText, remark } = await this.$fetch('queryShopById', { id: this.id })
this.status = status
this.statusDesc = status == '2' ? `${status_dictText}${remark}` : status_dictText
} catch (err) {
console.log('--err', err)
}
uni.stopPullDownRefresh();
},
async onSubmit() {
try {
@ -198,8 +276,10 @@ export default {
longitude,
address,
}
let api = this.id ? 'updateShop' : 'addShop'
await this.$fetch('addShop', params)
await this.$fetch(api, params)
uni.showToast({
title: '提交成功',
@ -227,6 +307,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 {
padding: 28rpx 30rpx;
}


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

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


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

@ -83,6 +83,7 @@
},
data() {
return {
orderId: null,
selectedCoupon: [],
num: 1,
coupon: {},
@ -105,8 +106,9 @@
},
...mapState(['userInfo', 'payOrderProduct']),
},
onLoad(args) {
onLoad({ id }) {
this.$store.commit('getUserInfo')
this.orderId = id
},
onShow() {
this.getCouponList()
@ -128,24 +130,27 @@
this.selectedCoupon = [1]
},
async fetchCreateOrder() {
async fetchPayOrder() {
// todo: check
let params = {
itemId: this.payOrderProduct[0].id,
amount: this.totalPrice,
payType : this.payMethod,
// id: this.payOrderProduct[0].id,
// num: this.payOrderProduct[0].num,
// 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
},
@ -153,7 +158,7 @@
try {
const res = await this.fetchCreateOrder()
const res = await this.fetchPayOrder()
if (!res.success) {
return
@ -162,6 +167,7 @@
if (this.payMethod == 1) { //
} else { //
console.log('--发起支付接口回调', res)
await uni.requestPaymentWxPay(res)
}
@ -174,59 +180,7 @@
url: '/pages/index/order'
})
} 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