123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 |
- // pages/welfareMall/writeOff/writeOff.js
- import WelfareMall from '../../../api/welfareMall'
- import { parseTime } from '../../../utils/util'
- import {getMobileCache, getPhoneNumber as getPhoneNumberSync} from '../../../utils/user'
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- isLogin: false,
- page: 1,
- pageSize: 10,
- lock: false,
- noResult: false,
- noMore: false,
- mobileTop: 'TONY WU',
- hexiaoList: [],
- storeList: [],
- index: 0,
- storeNo: '',
- startDate: '',
- endDate: '',
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- wx.hideShareMenu();
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- this.setData({
- isLogin: getMobileCache() != ''
- })
- if(this.data.isLogin){
- this.getHexiaoList();
- this.getStoreListByStaff();
- } else {
- wx.switchTab({
- url:"/pages/welfareMall/personal/personal",
- })
- }
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- if (this.data.lock || this.data.noMore) {
- return
- }
- this.data.lock = true
- this.data.page++
- this.getHexiaoList();
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
- // 获取核销记录
- getHexiaoList: function() {
- WelfareMall.getHexiaoList({
- page: this.data.page,
- pageSize: this.data.pageSize,
- mobile: getMobileCache(),
- storeNo: this.data.storeNo,
- startDate: this.data.startDate,
- endDate: this.data.endDate,
- }).then(res => {
- if (res.code == 200) {
- this.userHexiaoListView(res.data)
- }
- this.data.lock = false
- }).catch(_ => {
- console.log(_)
- this.data.lock = false
- })
- },
- userHexiaoListView: function(data) {
- if (!Array.isArray(data) || data.length == 0) {
- console.log("核销列表数据为空");
- if (this.data.page == 1) {
- this.setData({
- mobileTop:getMobileCache(),
- noResult: true
- })
- } else {
- this.setData({
- mobileTop:getMobileCache(),
- noMore: true
- })
- }
- return
- }
- data.forEach(v => {
- let usedTime = v.usedTime
- v.usedTime = parseTime(usedTime, "{y}.{m}.{d} {h}:{i}:{s}")
- })
- this.data.hexiaoList = this.data.hexiaoList.concat(...data)
- this.setData({
- mobileTop:getMobileCache(),
- hexiaoList: this.data.hexiaoList
- })
- },
- // 根据职员获取门店列表
- getStoreListByStaff: function() {
- WelfareMall.getStoreListByStaff({
- mobile: getMobileCache(),
- }).then(res => {
- if (res.code == 200) {
- this.userstoreListView(res.data)
- }
- this.data.lock = false
- }).catch(_ => {
- console.log(_)
- this.data.lock = false
- })
- },
- userstoreListView: function(data) {
- if (!Array.isArray(data) || data.length == 0) {
- console.log("门店列表数据为空");
- if (this.data.page == 1) {
- this.setData({
- mobileTop:getMobileCache(),
- noResult: true
- })
- } else {
- this.setData({
- mobileTop:getMobileCache(),
- noMore: true
- })
- }
- return
- }
- //增加全部门店空数据
- data.unshift({storeNo:"",storeName:"全部门店"})
- this.data.storeList = data
- this.setData({
- mobileTop:getMobileCache(),
- storeList: this.data.storeList
- })
- },
- //选择门店
- bindPickerChange: function (e) {
- console.log(e)
- this.setData({
- index: e.detail.value,
- hexiaoList: [],
- page: 1,
- pageSize: 10,
- lock: false,
- noResult: false,
- noMore: false,
- mobileTop: 'TONY WU',
- })
- let storeList = this.data.storeList
- if(storeList != null && storeList.length > 0){
- for(var i=0; i<storeList.length;i++){
- if(e.detail.value == i){
- // console.log(e.detail.value+'?'+i+'====='+storeList[i].storeNo)
- this.setData({
- storeNo: storeList[i].storeNo
- })
- break;
- }
- }
- }
- this.getHexiaoList();
- },
- //选择日期起期
- bindStartDateChange: function (e) {
- this.setData({
- startDate: e.detail.value,
- hexiaoList: [],
- page: 1,
- pageSize: 10,
- lock: false,
- noResult: false,
- noMore: false,
- mobileTop: 'TONY WU',
- })
- this.getHexiaoList();
- },
- //选择日期止期
- bindEndDateChange: function (e) {
- let that = this;
- if(that.data.startDate == null || that.data.startDate == ''){
- wx.showToast({
- title: '请选择分账时间起期',
- icon: 'none',
- duration: 1500
- })
- return;
- }
- this.setData({
- endDate: e.detail.value,
- hexiaoList: [],
- page: 1,
- pageSize: 10,
- lock: false,
- noResult: false,
- noMore: false,
- mobileTop: 'TONY WU',
- })
- this.getHexiaoList();
- },
- //清除日期
- toCloseDet: function (e) {
- this.setData({
- hexiaoList: [],
- startDate: '',
- endDate: '',
- page: 1,
- pageSize: 10,
- lock: false,
- noResult: false,
- noMore: false,
- mobileTop: 'TONY WU',
- })
- this.getHexiaoList();
- },
-
- toCopy: function(e){
- let orderSn = e.currentTarget.dataset.ordersn
- wx.setClipboardData({
- data: orderSn,
- success: function (res) {
- console.log(orderSn)
- }
- })
- }
- })
|