Browse Source

add api

voice
刘嘉炜 4 years ago
parent
commit
e419a6d346
  1. 2
      src/js/api.js
  2. 10
      src/js/once_name.js
  3. 1
      src/pages/store_list/store_list.vue
  4. 116
      src/pages/write_off/confirm_order/confirm_order.vue
  5. 90
      src/pages/write_off/operate/operate.vue
  6. 77
      src/pages/write_off/search_result/search_result.vue
  7. 24
      src/utils/util.js

2
src/js/api.js

@ -70,8 +70,8 @@ API['venue'] = {
API['writeOff'] = {
listVerifyRecord: `${ORIGIN}/admin/stadium/order/listVerifyRecord`, // 核销记录
assistantVerify: `${ORIGIN}/admin/stadium/order/assistantVerify`, // 商家助手-核销查询-核销
enterVerifyOrder: `${ORIGIN}/admin/stadium/order/enterVerifyOrder`, // 商家助手-核销查询-输入验证码
assistantVerify: `${ORIGIN}/admin/stadium/order/assistantVerify`, // 商家助手-核销查询-核销
}
export default { ORIGIN, API };

10
src/js/once_name.js

@ -0,0 +1,10 @@
// 监听器命名
// 避免命名冲突,误触监听器
export const WRITE_OFF_STORE_INFO = 'stadium_list';
export const WRITE_OFF_ORDER_INFO = 'order_info';
export default {
WRITE_OFF_STORE_INFO,
WRITE_OFF_ORDER_INFO,
}

1
src/pages/store_list/store_list.vue

@ -60,7 +60,6 @@ export default {
failMsg: '获取列表失败!'
})
.then(res=>{
console.log(res)
let _list = res.list || [];
if(page == 1) return this.storeList = _list;
if(_list.length<=0)return util.showNone('没有更多!');

116
src/pages/write_off/confirm_order/confirm_order.vue

@ -1,44 +1,77 @@
<template>
<view class="confirm-order">
<view class="co-container">
<view class="c-store-name">欧轩智能羽毛球馆(永泰店)</view>
<view class="c-store-name">{{orderInfo.stadium_name || '-'}}</view>
<view class="c-main-section">
<view class="s-line">
<view>
<text>订单编号</text>
<view><view>20195175645666</view></view>
<view><view>{{ orderInfo.order_no || '-' }}</view></view>
</view>
<view>(次卡)</view>
<view>{{orderInfo.order_type == 0?'(租场)':orderInfo.order_type == 1?'(次卡)':''}}</view>
</view>
<view class="s-line">
<view>
<text>用户昵称</text>
<view><view>周大强</view></view>
<view><view>{{ orderInfo.nickname || '-' }}</view></view>
</view>
</view>
<view class="s-line">
<view>
<text>预订项目</text>
<view><view>单人羽毛球次卡 (可随时使用) </view></view>
<text>验证码</text>
<view><view>{{ orderInfo.verify_code || '-' }}</view></view>
</view>
</view>
<view class="s-line">
<view>
<text>预定日期</text>
<view><view>2019-05-18 周五</view></view>
<!-- 租场 -->
<block v-if="orderInfo.order_type == 0">
<view class="s-line">
<view>
<text>预订项目</text>
<view><view>{{ orderInfo.venue_type_name || '-' }}</view></view>
</view>
</view>
</view>
<view class="s-line">
<view>
<text>预定场次</text>
<view class="s-line">
<view>
<view>平日+上午</view>
<view>平日+上午</view>
<text>预定日期</text>
<view><view>{{ orderInfo.date || '-' }}</view></view>
</view>
</view>
</view>
<view class="s-line">
<view>
<text>预定场次</text>
<view>
<view v-for="(e, i) in orderInfo.sessions" :key="i">{{e.date || ''}} {{e.duration || ''}}</view>
</view>
</view>
</view>
</block>
<!-- 次卡 -->
<block v-if="orderInfo.order_type == 1">
<view class="s-line">
<view>
<text>预订项目</text>
<view><view>{{ orderInfo.person_number_rule.name || '-' }}</view></view>
</view>
</view>
<view class="s-line">
<view>
<text>预定日期</text>
<view><view>{{ orderInfo.date || '-' }}</view></view>
</view>
</view>
<view class="s-line">
<view>
<text>预定场次</text>
<view>
<view v-for="(e, i) in orderInfo.sessions" :key="i">{{e.date || ''}} {{e.duration || ''}}</view>
</view>
</view>
</view>
</block>
</view>
<view class="c-more-ticket">
<!-- <view class="c-more-ticket">
<view class="mt-tip">该次卡订单有多张票请选择验证码核销多选</view>
<view class="mt-lines">
<view v-for="i in 3" :key="i">
@ -46,19 +79,58 @@
<image></image>
</view>
</view>
</view>
</view> -->
<view class="c-dotted-line"></view>
<view class="c-btns">
<view>确认核销</view>
<view>不核销</view>
<view @click="writeOffBtn">确认核销</view>
<view @click="cancelBtn">不核销</view>
</view>
</view>
</view>
</template>
<script>
import util from '../../../utils/util';
import { API } from '../../../js/api';
import { servers } from '../../../js/server';
import { WRITE_OFF_ORDER_INFO } from '../../../js/once_name';
export default {
data(){
return {
orderInfo: {}
}
},
onLoad(){
util.$_once(WRITE_OFF_ORDER_INFO, data => {
console.warn(data)
this.orderInfo = data;
})
},
methods: {
cancelBtn(){
util.routeTo();
},
writeOffBtn: util.debounce(function(){
let { orderInfo } = this;
servers.get({
url: API.writeOff.assistantVerify,
data: {
brand_id: orderInfo.brand_id,
stadium_id: orderInfo.stadium_id,
verify_code: orderInfo.verify_code,
},
isDefaultGet: false,
})
.then(res=>{
if(res.data.code == 0){
util.showNone(res.data.message || '操作成功!');
setTimeout(_=>util.routeTo(), 1200);
}else{
util.showNone(res.data.message || '操作失败!');
}
})
}, 300, true),
}
}
</script>

90
src/pages/write_off/operate/operate.vue

@ -2,33 +2,105 @@
<view class="operate-container">
<view class="store-bar">
<text>当前门店</text>
<picker>
<picker mode="selector" :range="stadiumList" range-key="name" @change="stadiumChange">
<view>
<input />
<image></image>
<input disabled v-model="curStadium.name" />
<image mode="aspectFit" src="/static/images/icon/arrow_c33.png"></image>
</view>
</picker>
</view>
<view class="c-scan-btn">
<image></image>
<view class="c-scan-btn" @click="scanCodeBtn">
<image mode="aspectFit" src="/static/images/icon/scan_code_btn.png"></image>
</view>
<view class="c-verification-code">
<view><input placeholder="输入订单验证码" /></view>
<view><input placeholder="输入订单验证码" v-model="iptCode" /></view>
<view @click="confirmBtn">确认核销</view>
</view>
</view>
</template>
<script>
import util from '../../../utils/util'
import util from '../../../utils/util';
import { API } from '../../../js/api';
import { servers } from '../../../js/server';
import { WRITE_OFF_STORE_NAME, WRITE_OFF_ORDER_INFO } from '../../../js/once_name';
import { mapState } from 'vuex';
export default {
data(){
return {
iptCode: '',
stadiumList: [],
curStadium: {},
}
},
computed: {
...mapState([ 'brandInfo' ]),
},
onLoad(){
util.$_once(WRITE_OFF_STORE_NAME, data => {
this.curStadium = data.curStadium;
this.stadiumList = data.stadiumList;
})
console.warn(this.brandInfo)
},
methods: {
confirmBtn(){
scanCodeBtn: util.debounce(function(){
uni.scanCode({
onlyFromCamera: true,
scanType: 'qrCode',
success: res=> {
console.warn('success--->', res);
if(util.changeLowerCase(res.scanType) !== 'qr_code')return util.showNone('不支持此类型!');
console.warn(res.result)
this.analysisOrder({ decrypt_text: res.result });
},
fail: function(err) {
util.showNone('扫码失败!');
console.warn('扫码失败--->', err);
}
})
}, 300, true),
stadiumChange(e){
let { stadiumList } = this;
this.curStadium = stadiumList[e.detail.value];
},
confirmBtn: util.debounce(function(){
this.analysisOrder({ verify_code: this.iptCode });
return
let _timeSta = new Date().getTime();
if(_timeSta%3 == 0)return util.routeTo(`/pages/write_off/confirm_order/confirm_order`, 'nT');
if(_timeSta%2 < 1)return util.routeTo(`/pages/write_off/null/null`, 'nT');
return util.routeTo(`/pages/write_off/confirm_order/confirm_order`, 'nT');
}, 300, true),
analysisOrder({ verify_code, decrypt_text }){
let { curStadium, brandInfo } = this;
if(!verify_code&!decrypt_text)return;
let _query = {
brand_id: brandInfo.brand.id,
stadium_id: curStadium.id,
}
if(!!verify_code)_query['verify_code'] = verify_code;
if(!!decrypt_text)_query['decrypt_text'] = decrypt_text;
servers.get({
url: API.writeOff.enterVerifyOrder,
data: _query,
isDefaultGet: false
})
.then(res=>{
if(res.data.code == 0){
let _data = res.data.data || {}
util.$_emit(WRITE_OFF_ORDER_INFO, {..._data})
util.routeTo(`/pages/write_off/confirm_order/confirm_order`, 'nT');
}else{
if(!!verify_code)return util.routeTo(`/pages/write_off/null/null?type=${'verify_code'}`, 'nT');
if(!!decrypt_text)return util.routeTo(`/pages/write_off/null/null?type=${'decrypt_text'}`, 'nT');
}
console.log('订单查询---->', res);
})
}
}
}
</script>
@ -71,7 +143,6 @@ export default {
flex-grow: 0;
width: 28upx;
height: 28upx;
background-color: skyblue;
}
}
}
@ -85,7 +156,6 @@ export default {
>image{
width: 172upx;
height: 172upx;
background-color: skyblue;
}
}
.c-verification-code{

77
src/pages/write_off/search_result/search_result.vue

@ -2,21 +2,21 @@
<view class="search-result">
<view class="store-bar">
<text>当前门店</text>
<picker>
<picker mode="selector" :range="stadiumList" range-key="name" @change="stadiumChange">
<view>
<input />
<image></image>
<input disabled v-model="curStadium.name" />
<image mode="aspectFit" src="/static/images/icon/arrow_c33.png"></image>
</view>
</picker>
</view>
<view class="r-timer-select">
<picker>
<picker mode="date">
<view>
<text>核销日期2020-08-27</text>
<image></image>
<image mode="aspectFit" src="/static/images/icon/arrow_c33.png"></image>
</view>
</picker>
<view>核销数量30</view>
<view>核销数量{{writeOffList.length || 0}}</view>
</view>
<view class="r-order-list">
<view class="l-item" v-for="i in 10" :key="i">
@ -49,26 +49,79 @@
import util from '../../../utils/util';
import { API } from '../../../js/api';
import { servers } from '../../../js/server';
import { mapState } from 'vuex';
import { WRITE_OFF_STORE_NAME } from '../../../js/once_name';
export default {
computed: {
...mapState([ 'brandInfo' ]),
},
data(){
return {
stadiumList: [], //
curStadium: {}, //
writeOffList: [] //
}
},
onLoad(){
this.getList();
this.initPage();
},
methods: {
stadiumChange(e){
let { stadiumList } = this;
this.curStadium = stadiumList[e.detail.value];
},
async initPage(){
let { brandInfo } = this;
try{
let _storeList = await this.getStoreList({ brand_id: brandInfo.brand.id || '' });
this.stadiumList = _storeList || [];
if(_storeList.length) this.curStadium = _storeList[0];
this.getList({
brand_id: brandInfo.brand.id || ''
});
}catch(err){
console.warn('加载数据失败!', err);
}
},
toOperate(){
let { stadiumList, curStadium } = this;
util.$_emit(WRITE_OFF_STORE_NAME, {
stadiumList,
curStadium,
})
util.routeTo(`/pages/write_off/operate/operate`, 'nT');
},
getList(){
getList({ brand_id }){
servers.get({
url: API.writeOff.listVerifyRecord,
data: {
brand_id: 63
},
data: { brand_id },
failMsg: '加载失败!',
})
.then(res=>{
let _list = res.list || [];
this.writeOffList = _list;
console.warn(res, 'jijjjjjjjjj')
})
},
getStoreList({
page=1,
page_size=9999,
brand_id='',
}){
return servers.get({
url: API.stadiumList,
data: {
page,
page_size,
brand_id,
},
failMsg: '获取列表失败!'
})
.then(res=>{
let _list = res.list || [];
return _list
})
}
}
}
@ -114,7 +167,6 @@ export default {
flex-grow: 0;
width: 28upx;
height: 28upx;
background-color: skyblue;
}
}
}
@ -135,7 +187,6 @@ export default {
vertical-align: middle;
width: 22upx;
height: 22upx;
background-color: skyblue;
}
}
}

24
src/utils/util.js

@ -340,6 +340,26 @@ function changeLowerCase(str){
return str.toString().toLocaleLowerCase();
}
// 大数据量跨页/跨组件传参------$_once && $_emit
// 单次监听器
// 到文件src\js\once_name.js,进行命名,防止命名冲突导致错误监听
function $_once(name, cb){
uni.$once(name + '',function(data){
cb&&cb(data);
})
setTimeout(_=>{
uni.$emit((name + '')+'1');
}, 50)
}
// 促发单次监听
function $_emit(name, data){
uni.$once((name + '')+'1',function(){
uni.$emit(name + '', data);
})
}
export default {
formatTime,
formatNumber,
@ -368,5 +388,7 @@ export default {
getQueryStr,
formatScene,
changeLowerCase,
isProfile
isProfile,
$_once,
$_emit
}
Loading…
Cancel
Save