Browse Source

feat: 接口对接;

pull/3/head
Fox-33 4 weeks ago
parent
commit
85e853c0f1
9 changed files with 78 additions and 33 deletions
  1. +2
    -2
      api/api.js
  2. +2
    -2
      api/fetch.js
  3. +2
    -2
      api/http.js
  4. +5
    -0
      api/model/exam.js
  5. +3
    -3
      pages_order/auth/agreementConfirmPopup.vue
  6. +0
    -2
      pages_order/auth/wxLogin.vue
  7. +2
    -0
      pages_order/components/agreementModal.vue
  8. +1
    -2
      pages_order/report/codeErrorPopup.vue
  9. +61
    -20
      pages_order/report/pay.vue

+ 2
- 2
api/api.js View File

@ -12,7 +12,7 @@ const config = {
}
export function api(key, data, callback, loadingTitle) {
export function api(key, data, callback, loadingTitle, disabledToast) {
let req = config[key]
if (!req) {
@ -72,7 +72,7 @@ export function api(key, data, callback, loadingTitle) {
}
return http.http(req.url, data, callback, req.method,
loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
loadingTitle || req.showLoading, loadingTitle || req.loadingTitle, disabledToast)
}


+ 2
- 2
api/fetch.js View File

@ -1,6 +1,6 @@
import api from './api.js'
const fetch = (key, data = {}, transform = true, loadingTitle) => {
const fetch = (key, data = {}, transform = true, loadingTitle, disabledToast = false) => {
return new Promise((resolve, reject) => {
const callback = (res) => {
@ -15,7 +15,7 @@ const fetch = (key, data = {}, transform = true, loadingTitle) => {
}
}
api(key, data, callback, loadingTitle)
api(key, data, callback, loadingTitle, disabledToast)
})
}


+ 2
- 2
api/http.js View File

@ -3,7 +3,7 @@ import Vue from 'vue'
import utils from '../utils/utils.js'
import store from '../store/store.js'
function http(uri, data, callback, method = 'GET', showLoading, title) {
function http(uri, data, callback, method = 'GET', showLoading, title, disabledToast) {
if(showLoading){
uni.showLoading({
@ -38,7 +38,7 @@ function http(uri, data, callback, method = 'GET', showLoading, title) {
console.error('登录过期');
store.commit('clearUserInfo')
utils.toLogin()
} else if(res.statusCode == 200 && res.data.code != 200
} else if(!disabledToast && res.statusCode == 200 && res.data.code != 200
&& res.data.code != 902){
uni.showToast({
mask: true,


+ 5
- 0
api/model/exam.js View File

@ -29,6 +29,11 @@ const api = {
limit : 500,
showLoading : true,
},
// 支付-查询兑换码
queryCodeById: {
url: '/exam/queryCodeById',
method: 'GET',
},
// 我的-我的答题
queryExamLogList: {
url: '/exam/queryExamLogList',


+ 3
- 3
pages_order/auth/agreementConfirmPopup.vue View File

@ -6,10 +6,10 @@
用户隐私保护提示
</view>
<view class="content">
在你使用 普兆医疗服务之前请仔细阅读我已阅读并同意
<text class="highlight" @click="$refs.modal.open('config_agreement', '服务协议与隐私条款')">服务协议与隐私条款</text>
在你使用 {{ configList.app_name }}服务之前请仔细阅读我已阅读并同意
<text class="highlight" @click="$refs.modal.open('config_privacy', '服务协议与隐私条款')">服务协议与隐私条款</text>
<text class="highlight" @click="$refs.modal.open('config_privacy', '个人信息保护指引')">个人信息保护指引</text>
<text class="highlight" @click="$refs.modal.open('config_agreement', '个人信息保护指引')">个人信息保护指引</text>
如你同意该指引请点击同意开始使用本小程序
</view>
<view class="footer">


+ 0
- 2
pages_order/auth/wxLogin.vue View File

@ -29,10 +29,8 @@
</view>
<view class="desc">
阅读并同意我们的
<!-- todo: 替换配置项key -->
<text class="highlight" @click="$refs.modal.open('config_privacy', '服务协议与隐私条款')">服务协议与隐私条款</text>
以及
<!-- todo: 替换配置项key -->
<text class="highlight" @click="$refs.modal.open('config_agreement', '个人信息保护指引')">个人信息保护指引</text>
</view>
</view>


+ 2
- 0
pages_order/components/agreementModal.vue View File

@ -68,6 +68,8 @@ export default {
.content {
padding: 8rpx 32rpx 40rpx 32rpx;
max-height: 70vh;
overflow-y: scroll;
font-size: 28rpx;
font-family: PingFang SC;
font-weight: 400;


+ 1
- 2
pages_order/report/codeErrorPopup.vue View File

@ -8,8 +8,7 @@
<view class="flex flex-column popup__view">
<text class="title">兑换码输入有误请与客服确认</text>
<text class="desc">联系客服获取抵扣码</text>
<!-- todo: check key -->
<image class="img" src="" :show-menu-by-longpress="true"></image>
<image class="img" :src="configList.customer_service_qrcode" :show-menu-by-longpress="true" mode="widthFix"></image>
<button class="btn" @click="close">好的</button>
</view>
</uv-popup>


+ 61
- 20
pages_order/report/pay.vue View File

@ -6,8 +6,7 @@
<view>实付金额</view>
<view class="flex price">
<view>¥</view>
<!-- todo: fetch -->
<view class="highlight">24.00</view>
<view class="highlight">{{ payAmount }}</view>
</view>
<view class="flex flex-column contact">
<view>联系客服获取抵扣码</view>
@ -27,7 +26,7 @@
<view class="form-item-label">选择支付方式</view>
<view class="form-item-content">
<uv-radio-group
v-model="selectedId"
v-model="form.payment"
placement="column"
shape="circle"
size="30rpx"
@ -41,8 +40,7 @@
<view>微信支付</view>
</view>
<view>
<!-- todo: check value -->
<uv-radio :name="1"></uv-radio>
<uv-radio :name="0"></uv-radio>
</view>
</view>
</view>
@ -53,8 +51,7 @@
<view>兑换码抵扣支付</view>
</view>
<view>
<!-- todo: check value -->
<uv-radio :name="0"></uv-radio>
<uv-radio :name="1"></uv-radio>
</view>
</view>
</view>
@ -62,7 +59,7 @@
</view>
</uv-form-item>
</view>
<view class="form-item is-child">
<view class="form-item is-child" v-if="form.payment == 1">
<uv-form-item prop="code" :customStyle="formItemStyle">
<view class="flex row">
<view class="form-item-label">兑换码</view>
@ -98,12 +95,12 @@
return {
batchNo: null,
form: {
payment: null,
payment: 0,
code: null,
},
rules: {
'payment': {
type: 'string',
type: 'number',
required: false,
message: '请选择支付方式',
},
@ -116,21 +113,65 @@
formItemStyle: { padding: 0 },
}
},
computed: {
payAmount() {
return Number(this.configList.pay_amount)
}
},
onLoad(arg) {
const { batchNo } = arg
this.batchNo = batchNo
},
methods: {
onPay() {
// todo
// todo: check code is error
// if error
// this.$refs.codeErrorPopup.open()
uni.redirectTo({
url: `/pages_order/report/userInfo?batchNo=${this.batchNo}`
})
async onPay() {
try {
await this.$refs.form.validate()
const {
payment,
code,
} = this.form
let payAmount = this.payAmount
let discountAmount = 0
if (payment == 1) { //
const infoRes = await this.$fetch('queryCodeById', { code }, false, null, true)
const { result: infoResult } = infoRes
if (!infoResult || infoResult?.isUse !== '0') {
this.$refs.codeErrorPopup.open()
return
}
discountAmount = infoResult.discountAmount
payAmount -= discountAmount
}
const params = {
batchNo: this.batchNo,
payAmount,
discountAmount,
code,
}
const result = await this.$fetch('createOrder', params)
await uni.requestPaymentWxPay({ result })
uni.showToast({
title: '支付成功',
icon: 'none'
})
setTimeout(() => {
uni.redirectTo({
url: `/pages_order/report/userInfo?batchNo=${this.batchNo}`
})
}, 700)
} catch (err) {
}
},
},
}


Loading…
Cancel
Save