diff --git a/src/js/api.js b/src/js/api.js index 179703e..90f0a4b 100644 --- a/src/js/api.js +++ b/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 }; diff --git a/src/js/once_name.js b/src/js/once_name.js new file mode 100644 index 0000000..d32a5a4 --- /dev/null +++ b/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, +} \ No newline at end of file diff --git a/src/pages/store_list/store_list.vue b/src/pages/store_list/store_list.vue index 4fdbad0..05a87e7 100644 --- a/src/pages/store_list/store_list.vue +++ b/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('没有更多!'); diff --git a/src/pages/write_off/confirm_order/confirm_order.vue b/src/pages/write_off/confirm_order/confirm_order.vue index 33c557d..b39063e 100644 --- a/src/pages/write_off/confirm_order/confirm_order.vue +++ b/src/pages/write_off/confirm_order/confirm_order.vue @@ -1,44 +1,77 @@ diff --git a/src/pages/write_off/operate/operate.vue b/src/pages/write_off/operate/operate.vue index a8dcaf4..6970de4 100644 --- a/src/pages/write_off/operate/operate.vue +++ b/src/pages/write_off/operate/operate.vue @@ -2,33 +2,105 @@ 当前门店 - + - - + + - - + + - + 确认核销 @@ -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{ diff --git a/src/pages/write_off/search_result/search_result.vue b/src/pages/write_off/search_result/search_result.vue index a5cff29..5dc3771 100644 --- a/src/pages/write_off/search_result/search_result.vue +++ b/src/pages/write_off/search_result/search_result.vue @@ -2,21 +2,21 @@ 当前门店 - + - - + + - + 核销日期:2020-08-27 - + - 核销数量:30 + 核销数量:{{writeOffList.length || 0}} @@ -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; } } } diff --git a/src/utils/util.js b/src/utils/util.js index 56f633b..9799928 100644 --- a/src/utils/util.js +++ b/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 }