const { join } = require("../../resource/js/function.js"); var a = getApp(), i = wx.getRecorderManager(), t = (wx.getBackgroundAudioManager(), require("../../resource/js/function.js")); let goodsList = [{ actEndTime: '2021/9/08 10:00:43' }] Page({ data: { countDownList: [], actEndTimeList: [], //投票id voteid: 0, // tabBar配置 config: { isindexfollow: !1, isdetailfollow: !1, footbgcolor: "", footcolor: "", footsearchbgcolor: "", footsearchcolor: "", buttonbgcolor: "", buttoncolor: "", isvotegiftpop: !1, isgift: !1, // isgift:true, userlogin: "1", isIphoneX: false, open: false }, //搜索显示 search: { show: !1 }, // 投票显示配置 index: { showlist: "news", limit: 10, start: 0, pulluploading: !0, ispulluploading: !1, size: { news: { left: 0, right: 0 }, hot: { left: 0, right: 0 } }, width: "" }, // 资源控制 join: { images: [{ isadd: !1, src: "../../resource/image/iconfont-tianjia.png" }, { isadd: !1, src: "../../resource/image/iconfont-tianjia.png" }, { isadd: !1, src: "../../resource/image/iconfont-tianjia.png" }, { isadd: !1, src: "../../resource/image/iconfont-tianjia.png" }, { isadd: !1, src: "../../resource/image/iconfont-tianjia.png" } ], video: [{ isadd: !1, src: "", name: "点击选择上传视频:未选择", url: "" }], music: [{ isadd: !1, src: "", name: "点我开始录音", url: "" }], subbtn: { isdisabled: !0, text: "确认提交" }, validates: { username: !1, telephone: !1, image: !1, resume: !1, video: !1, music: !1 }, joinInfo: {}, area: '', typesId: '', typesName: '', region: [], }, joinok: {}, personal:{}, mallId:[0,1], checking: {}, detail: { swiperheight: 60, giftbox: !0, font: "给TA投票", topage: "1", id: "", username: "", images: "", resume: "", telephone: "", pollcount: "", gifts: "", reply: "", giftrecords: "", ranking: "", haibao: "", imgurl: "", imgbg: "", maxpic: !1, maximg: "", video: "", videoshow: "none", musicshow: "music_off" }, ranking: { start: 20, limit: 20, ispulluploading: !1, nowType: 'renqi', tabs: 'shangcheng', mall_list: [], rankIndex: '0', rankArea: ['全部','罗湖区', '南山区', '福田区', '宝安区', '龙华区', '龙岗区', '光明区', '盐田区','大鹏新区','前海新区'] }, mall: { nowNav: 1, areaIndex: '' }, area: { region: ['广东省', '深圳市', '罗湖区'] }, rule: {}, showpage: "index", footerindex: 1, page: 1, mallId: '', reply: { content: "", length: "" }, memberinfo: { id: 0 }, CheckItem: [{ value: '1', name: '承诺48小时无条件退换', checked: false }, { value: '2', name: '承若公示制度,无欺诈行为、无假冒伪劣、“三无”过期商品', checked: false }, { value: '3', name: '营业场所需挂牌上岗、主动热情提供售前、售中、售后服务', checked: false }, { value: '4', name: '建立高效消费者投诉处理,投诉有专人负责并有处理结果', checked: false }, { value: '5', name: '年度内在工商、税务、质检、物价、卫生、劳动、安监、消协、银行等部门或机构没有被处罚记录或不良记录', checked: false } ], checkNum: 0, giftList: [], isArea: '罗湖区', Addresslist:[], hairCurl:{ activeIndex:1 , update:{ type:1, name:'', img:'../../resource/image/iconfont-tianjia.png', count:'', content:'', discounts:'', money:'', start_time:'', end_time:'', isadd: !1, address:'', id:'' } }, hairCurlDate:{}, myjoin:{}, luckDraw:{ opoUpShow:false, winsShow:false, timesNoShow:false, awardsList: {}, awardIndex:0, list: [], statusBarHeight: getApp().globalData.statusBarHeight, scrollHeight: 200, windowWidth:0, windowHeight:0, size: 600, awardsConfig: { slicePrizes: [ // { text: "猪脚饭", img: "../../resource/image/l0g0.png", title: "积分券x1", num: "20", x: "1" }, // { text: "鸡排饭", img: "../../resource/image/l0g0.png", title: "积分券x1", num: "20", x: "2" }, // { text: "卤肉饭", img: "../../resource/image/l0g0.png", title: "积分券x1", num: "20", x: "1" }, // { text: "香肠饭", img: "../../resource/image/l0g0.png", title: "积分券x3", num: "20", x: "2" }, // { text: "酸菜鱼", img: "../../resource/image/l0g0.png", title: "积分券x1", num: "20", x: "1" }, // { text: "水煮肉片", img: "../../resource/image/l0g0.png", title: "积分券x1", num: "20", x: "2" }, // { text: "梅菜扣肉", img: "../../resource/image/l0g0.png", title: "积分券x1", num: "20", x: "1" }, // { text: "鸡丁饭", img: "../../resource/image/l0g0.png", title: "积分券x1", num: "20", x: "1" } ], }, }, luckDrawDates:{}, luckDrawRinkDates:[], myLottery:{ status:0, page:1, activeIndex:0, list:{}, showDialog: false, qrcode:'' }, destroyInfo:{}, destroyList:{ status:0, page:1, activeIndex:0, list:{}, }, showDialog:false, giftData:{ activeIndex:0, list:{}, } }, addCancel(e){ console.info(e) var t=this; a.util.request({ url: "entry/wxapp/addCancel", data: e, success: function (a) { console.log(a.data); t.setData({ showpage: "destroy", 'destroyInfo.id':a.data.data }); console.info(t.data.destroyInfo) } }) }, cancel(e){ console.info(e) a.util.request({ url: "entry/wxapp/cancel", data: { id:e.currentTarget.dataset.id, user_id: e.currentTarget.dataset.user, }, success: function (res) { console.info(res) wx.showToast({ title: '核销成功!' }) this.setData({ 'destroyInfo.ishexiao': true }) } }); }, saoma(){ // 只允许从相机扫码 var i=this; wx.scanCode({ onlyFromCamera: true, success (res) { console.log(res) i.testhexiao(res); } }) }, getQueryString(name,url) { var reg = new RegExp('(^|&|/?)' + name + '=([^&|/?]*)(&|/?|$)', 'i') var r = url.substr(1).match(reg) if (r != null) { // console.log("r = " + r) // console.log("r[2] = " + r[2]) return r[2] } return null; }, testhexiao(i){ var path=this.getQueryString('scene',i.path), // type=this.getQueryString('path'), d = decodeURIComponent(path).split(","); console.info(path) console.info(d) var user=wx.getStorageSync('userInfo').memberInfo var e=this, c = d[2], id=d[0], r = d[1]; // console.info(d) a.util.request({ url: "entry/wxapp/getawardinfo", data: { user_id: r, award_id: c, id:id }, success: function (a) { console.log(a.data); var data={ id:id, user_id:r, award_id:c, source:a.data.data.source, shop_user_id:user.id } e.setData({ showpage: "destroy", destroyInfo:a.data.data.info, 'destroyInfo.user_id':r }); e.addCancel(data) } }) }, /** * 控制 pop 的打开关闭 * 该方法作用有2: * 1:点击弹窗以外的位置可消失弹窗 * 2:用到弹出或者关闭弹窗的业务逻辑时都可调用 */ toggleDialog(e) { this.setData({ 'myLottery.showDialog': !this.data.myLottery.showDialog }) if(this.data.myLottery.showDialog){ this.setData({ 'myLottery.qrcode':'https://xcx.zgzmdz.com/addons/qf_happyvote/hb/'+ e.currentTarget.dataset.qrcode, }) } }, LucktoggleDialog(e) { this.setData({ showDialog: !this.data.showDialog }) if(this.data.showDialog){ this.lotteryranking() } }, lotteryranking(){ var i=this a.util.request({ url: "entry/wxapp/lotteryranking", data: { }, success: function (a) { console.log(a.data); i.setData({ luckDrawRinkDates: a.data.data.list }) console.info(a.data.data.list) } }) }, tabNavdestroyList(e){ var i=this; i.setData({ 'destroyList.activeIndex': e.currentTarget.dataset.types, 'destroyList.status': e.currentTarget.dataset.types }); i.getdestroyList() }, tabNavmyLottery(e){ console.info(e) var i=this; i.setData({ 'myLottery.activeIndex': e.currentTarget.dataset.types, 'myLottery.status': e.currentTarget.dataset.types }); i.getmyLottery() }, tabNavGift(e){ console.info(e) var i=this; i.setData({ 'giftData.activeIndex': e.currentTarget.dataset.types, }); }, luckDrawLoad(){ var that = this; that.initAdards(true) wx.getSystemInfo({ success: function (res) { that.setData({ 'luckDraw.windowWidth': res.windowWidth, 'luckDraw.contentHeight': res.windowHeight, 'luckDraw.windowHeight': res.windowHeight, 'luckDraw.scrollHeight': res.windowHeight - res.windowWidth / 750 * (getApp().globalData.statusBarHeight * 2 + 98) }); }, }) let list = that.data.luckDraw.awardsConfig.slicePrizes //外框灯 that.setData({ 'luckDraw.list': list.concat(list) }); }, //初始化奖品数据 计算角度 initAdards(type) { var that = this; var user=wx.getStorageSync('userInfo').memberInfo a.util.request({ url: "entry/wxapp/getlottery", data: { user_id: user.id, }, showLoading:type, success: function (res) { console.info(res) that.setData({ luckDrawDates:res.data.data, 'luckDraw.awardsConfig.slicePrizes': res.data.data.award, 'luckDrawDates.avatar': user.avatar, }) var awardsConfig = that.data.luckDraw.awardsConfig; var t = awardsConfig.slicePrizes.length; // 选项长度 var e = 1 / t, i = 360 / t, r = i - 90; for (var g = 0; g < t; g++) { awardsConfig.slicePrizes[g].item2Deg = g * i + 90 - i / 2 + "deg"; //当前下标 * 360/长度 + 90 - 360/长度/2 awardsConfig.slicePrizes[g].afterDeg = r + "deg"; awardsConfig.slicePrizes[g].opacity = '1'; } console.info(awardsConfig) that.setData({ 'luckDraw.turnNum': e, // 页面的单位是turn 'luckDraw.awardsConfig': awardsConfig, }) } }); }, /** * 抽奖处理函数: */ getLottery: function () { let that = this; var user=wx.getStorageSync('userInfo').memberInfo a.util.request({ url: "entry/wxapp/lottery", data: { user_id: user.id, lottery_id:that.data.luckDrawDates.lottery_id }, showLoading:false, success: function (res) { console.info(res) // 获取奖品配置 let awardsConfig = that.data.luckDraw.awardsConfig, runNum = 10, len = awardsConfig.slicePrizes.length, awardIndex; for(var i=0;i item.name); this.setData({ 'join.joinInfo.mall_list': multiArray }) } }, bindPickerChange: function (e) { var _this = this; console.log(e); this.setData({ 'join.mallId': this.data.Addresslist[e.detail.value[0]].list[e.detail.value[1]].id, 'join.mallName':this.data.Addresslist[e.detail.value[0]].list[e.detail.value[1]].name }) // if (_this.data.join.region.length != 0 && _this.data.join.typesName != null) { // _this.getshangquan() // } }, bindPickerChange4(e) { var _this = this; _this.setData({ 'join.mallId': _this.data.join.joinInfo.mall_list[e.detail.value].id, 'join.mallName': _this.data.join.joinInfo.mall_list[e.detail.value].name }) }, getshangquan() { var _this = this; a.util.request({ url: "entry/wxapp/Getmalls", data: { voteid: _this.data.voteid, type: _this.data.join.typesId, area: _this.data.join.region }, success: function (res) { _this.setData({ 'join.joinInfo.mall_list': res.data.data.mall_list }) } }) }, bindPickerChange2: function (e) { var _this = this; _this.setData({ 'join.storeId': _this.data.join.joinInfo.store_types[e.detail.value].id, 'join.storeName': _this.data.join.joinInfo.store_types[e.detail.value].name }) }, bindPickerChange3(e) { var _this = this; this.setData({ 'join.region': e.detail.value }) if (_this.data.join.region.length != 0 && _this.data.join.typesName != null) { _this.getshangquan() } }, rnakAreaChange(e) { var i = this; let index = e.detail.value; let area = this.data.ranking.rankArea[index] == '全部' ? '' : this.data.ranking.rankArea[index]; a.util.request({ url: 'entry/wxapp/RankingsLevel', data: { area: area, rankings_type: i.data.ranking.tabs, start: 0, type: i.data.ranking.nowType || 'renqi', limit: i.data.ranking.limit }, success: function (res) { if (res.errno == 1) { return; } i.setData({ 'ranking.mall_list': res.data.data, 'ranking.rankIndex': index }) } }) }, tab1(e) { let area = this.data.ranking.rankArea[this.data.ranking.rankIndex] == '全部' ? '' : this.data.ranking.rankArea[this.data.ranking.rankIndex]; var status = e.currentTarget.dataset.status var i = this; i.setData({ 'ranking.tabs': status }) a.util.request({ url: 'entry/wxapp/RankingsLevel', data: { area: area, rankings_type: i.data.ranking.tabs, start: 0, type: i.data.ranking.nowType || 'renqi', limit: i.data.ranking.limit }, success: function (res) { console.log(res); i.setData({ 'ranking.mall_list': res.data.data }) } }) }, tab(e) { let area = this.data.ranking.rankArea[this.data.ranking.rankIndex] == '全部' ? '' : this.data.ranking.rankArea[this.data.ranking.rankIndex]; var i = this; var type = e.currentTarget.dataset.type i.setData({ 'ranking.nowType': type }) // // if( _this.data.ranking.tabs == 'dianzhang' ){ // t.getrankings(_this, type) // // } else { // _this.getMall() // // } a.util.request({ url: 'entry/wxapp/RankingsLevel', data: { area: area, rankings_type: i.data.ranking.tabs, start: 0, type: i.data.ranking.nowType || 'renqi', limit: i.data.ranking.limit }, success: function (res) { i.setData({ 'ranking.mall_list': res.data.data }) } }) }, bindRegionChange: function (e) { console.log('picker发送选择改变,携带值为', e.detail.value) this.setData({ 'area.region': e.detail.value }) this.mall(this.data.voteid, this.data.uid) }, mapchooseLocation() { let _this=this; wx.chooseLocation({ success: res => { let area = res.address.slice(6, 9); // this.getshop(area); this.setData({ 'join.joinInfo.store_Address': res.name }) }, fail:function(){ wx.getSetting({ success: res => { console.log(res); if (!res.authSetting['scope.userLocation']) { wx.showModal({ title: '是否授权当前位置', content: '需要获取您的地理位置,请确认授权,否则地图功能将无法使用', success: function (tip) { if (tip.confirm) { wx.openSetting({ success: function (data) { if (data.authSetting["scope.userLocation"] === true) { wx.showToast({ title: '授权成功', icon: 'success', duration: 1000 }) //授权成功之后,再调用chooseLocation选择地方 wx.chooseLocation({ success: function(res) { _this.setData({ 'join.joinInfo.store_Address': res.name }) }, }) } else { wx.showToast({ title: '授权失败', icon: 'success', duration: 1000 }) } } }) } } }) } } }) } }) }, changeTab(e) { let area = e.target.dataset.area; if (area == this.data.isArea) { return; } this.data.area.region[2] = area; this.setData({ isArea: area }) this.mall(this.data.voteid, this.data.uid); }, onLoad: function (i) { // 倒计时 // let endTimeList = []; // // 将活动的结束时间参数提成一个单独的数组,方便操作 // goodsList.forEach(o => { // endTimeList.push(o.actEndTime) // }) // this.setData({ // actEndTimeList: endTimeList // }); // if (this.isIphoneX()) { this.setData({ ['config.isIphoneX']: true }) } var e = this, o = wx.getStorageSync("userInfo"); if ("" != o.memberInfo && void 0 !== o.memberInfo) { var n = e.data.config; n.userlogin = 0, e.setData({ config: n }); var s = o.memberInfo; console.log(s), e.setData({ memberinfo: s }); }else{ e.bindGetUserInfo() } t.initpage(e); if(i.type!=1){ if (i.scene) var d = decodeURIComponent(i.scene).split(","), c = d[0], r = d[1]; else var c = i.voteid, r = i.joinid; "" != c && c > 0 && (e.setData({ voteid: c }), "" != r && r > 0 && setTimeout(function () { a.util.request({ url: "entry/wxapp/joininfo", data: { voteid: e.data.voteid, joinid: r }, success: function (a) { console.log(a.data); var i = a.data.data, t = e.data.detail; t.id = i.id, t.username = i.username, t.images = i.images, t.resume = i.resume, t.telephone = i.telephone, t.pollcount = i.pollcount, t.gifts = i.gifts, t.giftrecords = i.giftrecords, t.ranking = i.ranking, t.haibao = !1, t.video = i.video, t.music = i.music, t.reply = i.reply, t.isreply = !1, t.imgurl = "", t.imgbg = "0", e.setData({ detail: t, showpage: "detail" }); } }) }, 100)) }else{ var d = decodeURIComponent(i.scene).split(","), c = d[2], id=d[0], r = d[1]; a.util.request({ url: "entry/wxapp/getawardinfo", data: { user_id: r, award_id: c, id:id }, success: function (a) { console.log(a.data); var data={ id:id, user_id:r, award_id:c, source:a.data.data.source, shop_user_id:o.memberInfo.id } e.setData({ showpage: "destroy", destroyInfo:a.data.data.info }); e.addCancel(data) } }) } }, getshop(area) { var _this = this; let area1 = area || ''; a.util.request({ url: 'entry/wxapp/shop', data: { // area: area1, voteid: this.data.voteid }, success: function (res) { let mall=[]; mall[0] = res.data.data.map(item => item.area); mall[1] = res.data.data[0].list.map(item => item.name); _this.setData({ Addresslist:res.data.data, 'join.joinInfo.mall_list': mall }) } }) }, getstoretype() { var _this = this; a.util.request({ url: 'entry/wxapp/storetype', success: function (res) { _this.setData({ 'join.joinInfo.store_types': res.data.data }) } }) }, close() { var _this = this; _this.setData({ 'config.userlogin': 0, footerindex: 1 }) t.initpage(_this) }, tabNav(e) { this.setData({ 'mall.nowNav': e.currentTarget.dataset.types }) this.mall(this.data.voteid, this.data.uid) }, mall(e, uid) { var _this = this; a.util.request({ url: 'entry/wxapp/index', data: { state:'aa', area: _this.data.area.region, // voteid: e, uid, type: _this.data.mall.nowNav, position: 1 }, success: function (res) { _this.setData({ mall: res.data.data, 'index.is_join': res.data.data.is_join, 'mall.nowNav': _this.data.mall.nowNav, 'mall.areaIndex': _this.data.mall.areaIndex }) } }) }, onReady: function () {}, onShow: function () {}, onHide: function () {}, onUnload: function () {}, onShareAppMessage: function (i) { var t = this, e = t.data.detail; return "" != e.id ? (console.log(t.data.voteid), console.log(e.id), { title: t.data.config.wxappdetailsharetitle.replace("{username}", e.username), path: "/qf_happyvote/pages/index/index?voteid=" + t.data.voteid + "&joinid=" + e.id, imageUrl: e.images[0], success: function (i) { a.util.message("转发成功", "", "success"); } }) : { // title: t.data.config.wxappsharetitle, title:'深圳店长节评选', path: "/qf_happyvote/pages/index/index?voteid=" + t.data.voteid, // imageUrl: t.data.config.wxappshareimage, success: function (i) { a.util.message("转发成功", "", "success"); } }; }, bindGetUserInfo: function (i) { console.log(i.detail.userInfo); var e = this, o = e.data.config; o.userlogin = 0, e.setData({ config: o }), a.util.showLoading(), a.util.getUserInfo(function (a) { console.info(a) var i = wx.getStorageSync("userInfo").memberInfo; e.setData({ memberinfo: i, footerindex: 1 }), t.initpage(e), wx.hideLoading(); }); }, getgift() { var i = this; a.util.request({ url: "entry/wxapp/gift", data: { start: 0, voteid: i.data.voteid, limit: 10 }, success: function (res) { console.log(res) i.setData({ giftList: res.data.data }) } }); }, getMall() { var i = this; a.util.request({ url: "entry/wxapp/RankingsLevel", data: { rankings_type: i.data.ranking.tabs, start: 0, type: i.data.ranking.nowType || 'renqi', limit: i.data.ranking.limit }, success: function (res) { i.setData({ 'ranking.mall_list': res.data.data }) } }); }, // 优惠卷列表 myticket(){ var i = this; var user=wx.getStorageSync('userInfo').memberInfo a.util.request({ url: "entry/wxapp/myticket", data: { user_id: user.id, page: 1, limit: 10 }, success: function (res) { console.info(res) i.setData({ 'hairCurlDate': res.data.data }) } }); }, //个人中心 myjoin(){ var i = this; var user=wx.getStorageSync('userInfo').memberInfo a.util.request({ url: "entry/wxapp/myjoin", data: { user_id: user.id }, success: function (res) { console.info(res) i.setData({ 'myjoin': res.data.data, 'myjoin.avatar':user.avatar }) } }); }, //获取我的奖券列表 getmyLottery(){ var i = this; var user=wx.getStorageSync('userInfo').memberInfo a.util.request({ url: "entry/wxapp/myticketlist", data: { user_id: user.id, status:i.data.myLottery.status, page:i.data.myLottery.page, limit:10 }, success: function (res) { console.info(res) i.setData({ 'myLottery.list': res.data.data.list, }) } }); }, //核销列表 getdestroyList(){ var i = this; var user=wx.getStorageSync('userInfo').memberInfo a.util.request({ url: "entry/wxapp/cancellist", data: { user_id: user.id, status:i.data.destroyList.status, page:i.data.destroyList.page, limit:10 }, success: function (res) { console.info(res) i.setData({ 'destroyList.list': res.data.data.list, }) } }); }, viewjump: function (a) { var i = this, e = a.currentTarget.dataset.topage; console.info(e) if (e == 'mall') { i.setData({ showpage: e, footerindex: 1 }) } if (e == 'destroyList') { i.setData({ showpage: e, footerindex: 2 }) i.getdestroyList() } if(e== 'personal' ){ i.setData({ showpage: e, // showpage: 'luckDraw', // showpage: 'destroy', footerindex: 2 }) // var path1="qf_happyvote/pages/index/index?scene=4,68471,1&type=1"; // var path=i.getQueryString('scene',path1), // d = decodeURIComponent(path).split(","); // console.info(path) // console.info(d) i.myjoin() } if(e== 'myLottery' ){ i.setData({ showpage: e, footerindex: 2 }) i.getmyLottery() } if(e== 'luckDraw' ){ i.setData({ showpage: e, footerindex: 1 }) i.luckDrawLoad() } if(e== 'hairCurl' ){ i.setData({ showpage: e, footerindex: 2 }) i.myticket() } if (e == 'ranking') { i.getMall() } if (e == 'gift') { i.setData({ showpage: e, footerindex: 2 }) i.votereply() } if (e == 'myjoin') { this.getshop(); this.getstoretype(); if (!wx.getStorageSync('userInfo')) { i.setData({ 'config.userlogin': 1 }) } } if ("index" == e) { var o = i.data.detail; o.font = "给TA投票", o.giftbox = !0, i.setData({ showpage: e, detail: o, footerindex: 1 }); } else "join" == e || "joinok" == e || "checking" == e ? t.tojoinpage(i) : "ranking" == e ? (t.getrankings(i), i.setData({ showpage: e, footerindex: 3 })) : "rule" == e ? (i.setData({ showpage: e, footerindex: 4 }), i.notice()): "myjoin" == e && (i.data.config.isupdate ? t.mytojoinpage(i) : t.tojoinpage(i)); }, votereply(){ var i=this var user=wx.getStorageSync('userInfo').memberInfo a.util.request({ url: 'entry/wxapp/votereply', data: { user_id:user.id }, success: function (res) { console.info(res) i.setData({ 'giftData.list': res.data.data }) } }) }, notice(){ var i=this a.util.request({ url: 'entry/wxapp/notice', data: { }, success: function (res) { console.info(res) var content=res.data.data.list[0].message console.info(content.message) var article_content = content.replace(//g, '\div>'); console.info(article_content) res.data.data.list[0].message=article_content i.setData({ rule: res.data.data.list[0] }) console.info(i.data.rule.message) } }) }, showsearch: function (a) { var i = this, t = i.data.search; t.show = !0, i.setData({ search: t }); }, singletab(e) { var i = this; var type = e.currentTarget.dataset.type i.setData({ 'ranking.nowType': type }) a.util.request({ url: 'entry/wxapp/RankingsLevel', data: { rankings_type: 'dianzhang', start: 0, voteid: i.data.voteid, type: i.data.ranking.nowType || 'renqi', limit: i.data.ranking.limit }, success: function (res) { i.setData({ 'ranking.mall_list': res.data.data }) } }) }, singleBtn(){ let i=this; a.util.request({ url: 'entry/wxapp/RankingsLevel', data: { rankings_type: 'dianzhang', start: 0, voteid: i.data.voteid, type: i.data.ranking.nowType || 'renqi', limit: i.data.ranking.limit }, success: function (res) { if (res.errno == 1) { return; } i.setData({ 'ranking.mall_list': res.data.data, showpage:'single' }) } }) }, search: function (a) { var i = this, e = a.detail.value; if (e instanceof Object) { e = e.joinid; } var value = { joinid: e } t.search(i, value); }, jumpwxapp: function (a) { var i = this; wx.navigateToMiniProgram({ appId: i.data.config.wxapptoappid, path: i.data.config.wxapptopath, success: function (a) {} }); }, imgjumpwxapp: function (a) { var i = this, t = a.target.dataset.img, {appid,url} = a.target.dataset; if(url){ wx.navigateTo({ url: '/qf_happyvote/pages/web-view/index', events: { // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据 acceptDataFromOpenedPage: function (data) {} }, success: function (res) { // 通过eventChannel向被打开页面传送数据 res.eventChannel.emit('acceptDataFromOpenerPage', { url: url }) } }) } if (console.log(i.data.config.appid1), "1" == t) { if ("" == i.data.config.appid1) return !1; wx.navigateToMiniProgram({ appId: i.data.config.appid1, path: i.data.config.path1, success: function (a) { console.log(1); } }); } if ("2" == t) { if ("" == i.data.config.appid2) return !1; wx.navigateToMiniProgram({ appId: i.data.config.appid2, path: i.data.config.path2, success: function (a) {} }); } if ("3" == t) { if ("" == i.data.config.appid3) return !1; wx.navigateToMiniProgram({ appId: i.data.config.appid3, path: i.data.config.path3, success: function (a) {} }); } if ("8" == t) { if ("" == i.data.config.appid4) return !1; wx.navigateToMiniProgram({ appId: i.data.config.appid4, path: i.data.config.path4, success: function (a) {} }); } if ("9" == t) { if ("" == i.data.config.appid5) return !1; wx.navigateToMiniProgram({ appId: i.data.config.appid5, path: i.data.config.path5, success: function (a) {} }); } if ("4" == t) if (i.data.index.adfixed == i.data.index.advote || "" == i.data.config.adfixedappid) { if ("" == i.data.config.advoteappid) return !1; wx.navigateToMiniProgram({ appId: i.data.config.advoteappid, path: i.data.config.advotepath, success: function (a) {} }); } else { if ("" == i.data.config.adfixedappid) return !1; wx.navigateToMiniProgram({ appId: i.data.config.adfixedappid, path: i.data.config.adfixedpath, success: function (a) {} }); } if ("6" == t) { if ("" == i.data.config.adjoinappid) return !1; wx.navigateToMiniProgram({ appId: i.data.config.adjoinappid, path: i.data.config.adjoinpath, success: function (a) {} }); } if ("10" == t) { wx.navigateTo({ url: '/qf_happyvote/pages/web-view/index', events: { // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据 acceptDataFromOpenedPage: function (data) {} }, success: function (res) { // 通过eventChannel向被打开页面传送数据 res.eventChannel.emit('acceptDataFromOpenerPage', { url: 'https://xcx.zgzmdz.com/app/index.php?i=11&c=entry&actid=20&do=index&m=hxq_lottery' }) } }) } }, closesearch: function (a) { var i = this, t = i.data.search; t.show = !1, i.setData({ search: t }); }, indextabchange: function (a) { var i = this, t = a.currentTarget.dataset.totab, e = i.data.index; e.showlist = t, i.setData({ index: e }); }, loadlist: function (a) { var i = this, e = i.data.index, o = i.data.ranking; if (i.data.showpage == 'index') { i.setData({ page: i.data.page + 1 }) t.getlistmore(i) } e.ispulluploading || o.ispulluploading || (i.data.index.pulluploading && "index" == i.data.showpage && (e.ispulluploading = !0, i.setData({ index: e })), "ranking" == i.data.showpage && (o.ispulluploading = !0, i.setData({ ranking: o }), t.getranking(i, i.data.ranking.nowType))); }, delimage: function (a) { var i = this, t = a.currentTarget.dataset.index, p=a.currentTarget.dataset.type, e = i.data.join; if(p==1){ i.setData({ 'hairCurl.update.isadd': !1, 'hairCurl.update.img': "../../resource/image/iconfont-tianjia.png" }); }else{ e.images[t].isadd = !1, e.images[t].src = "../../resource/image/iconfont-tianjia.png", i.setData({ 'join.images': e.images }); } }, selimage: function (a) { var i = this, t = a.currentTarget.dataset.index, p=a.currentTarget.dataset.type, e = i.data.join; wx.chooseImage({ count: 1, sizeType: ["original", "compressed"], sourceType: ["album", "camera"], success: function (a) { if(p==1){ i.setData({ 'hairCurl.update.img': a.tempFilePaths[0], 'hairCurl.update.isadd': !0, }); }else{ e.images[t].isadd = !0, e.images[t].src = a.tempFilePaths[0], i.setData({ 'join.images': e.images }); } } }); }, goback() { var _this = this; _this.setData({ showpage: 'mall' }) }, dianzhang(e) { var _this = this; var mall_id = e.currentTarget.dataset.mall_id; let voteid = e.currentTarget.dataset.voteid; let time = e.currentTarget.dataset.time; this.setData({ actEndTimeList: time }) // 执行倒计时函数 this.countDown(); a.util.request({ url: 'entry/wxapp/MallJoinList', data: { voteid: voteid, mallid: mall_id }, success: function (res) { console.info(res) _this.setData({ voteid: voteid, showpage: 'index', nowMallId: mall_id, page: 1, 'index.dianzhang': res.data.data.dianzhang, 'index.jiaoyi': res.data.data.jiaoyi, 'index.liulan': res.data.data.liulan, 'index.piaoshu': res.data.data.piaoshu, 'index.newslist': res.data.data.newlist, 'index.hotlist': res.data.data.hotlist, 'index.endtime':res.data.data.end_time, // 'index.picture': res.data.data.picture, 'index.picture2': res.data.data.picture2, 'index.picture3': res.data.data.picture3, 'index.picture4': res.data.data.picture4, 'index.picture5':res.data.data.picture5 }); } }) }, selvideo: function (a) { var i = this, t = i.data.join; console.log(t) wx.chooseVideo({ sourceType: ["album", "camera"], maxDuration: 60, success: function (a) { t.video[0].isadd = !0, t.video[0].src = a.tempFilePath, t.video[0].name = "已选择视频", t.validates.video = !1, i.setData({ 'join.video': t.video }), console.log(t); } }); }, selmusic: function (a) { var t = this, e = t.data.join; if ("正在录音:请说话 (再次点击保存)" == e.music[0].name) return i.stop(), void i.onStop(function (a) { e.music[0].isadd = !0, e.music[0].src = a.tempFilePath, e.music[0].name = "录音已完成", e.validates.music = !1; a.tempFilePath; t.setData({ 'join.music': e.music }); }); e.music[0].name = "正在录音:请说话 (再次点击保存)", t.setData({ 'join.music': e.music }); var o = { duration: 6e4, sampleRate: 16e3, numberOfChannels: 1, encodeBitRate: 96e3, format: "mp3" }; i.start(o), i.onStart(function () { console.log("recorder start"); }); }, join: function (a) { console.log(a.detail.value) var i = this, e = a.detail.value; let trustList = ['trust_one', 'trust_two', 'trust_three', 'trust_four', 'trust_five'] e.mall_id = i.data.join.mallId e.store_type = i.data.join.storeId e.mall_type = i.data.join.typesId e.mall_area = i.data.join.region e.size=e.store_area e.resume=e.resume e.checkGroup.forEach(item => { e[trustList[parseInt(item) - 1]] = 1; }) if (e.username == "") { wx.showToast({ title: '请输入您的姓名', icon: 'none' }) return; } else if (e.telephone == "") { wx.showToast({ title: '请输入您的手机号码', icon: 'none' }) return; } else if (e.telephone.length < 11) { wx.showToast({ title: '手机号码有误,请重填', icon: 'none' }) return false; } // else if( i.data.join.region.length == 0 || i.data.join.region == null ){ // wx.showToast({ // title: '请选所在区域', // icon: 'none' // }) // return; // } else if (e.store_name == "") { wx.showToast({ title: '请填写店铺名称', icon: 'none' }) return; } else if (e.store_Address == null) { wx.showToast({ title: '请填写商户地址', icon: 'none' }) return; } else if (i.data.join.mallName == null) { wx.showToast({ title: '请选择商圈/商场', icon: 'none' }) return; } // else if ( i.data.join.mallName == null ) { // wx.showToast({ // title: i.data.join.typesId==1?'请选择商圈/商场':i.data.join.typesId==2?'请选择连锁品牌':'请选择特约商户', // icon: 'none' // }) // return; // } else if (!i.data.join.images[0].isadd) { wx.showToast({ title: '请上传图片', icon: 'none' }) return; }else if (e.MerchantCode == "") { wx.showToast({ title: '商户编码不能为空!', icon: 'none' }) return; } else if (e.MerchantNumber == "") { wx.showToast({ title: '商户终端号不能为空!', icon: 'none' }) return; } else if (!i.data.join.images[4].isadd) { wx.showToast({ title: '请上营业执照!', icon: 'none' }) return; }else if (e.resume == "") { wx.showToast({ title: '请发表您的诚信宣言', icon: 'none' }) return; } t.join(i, e); }, detail: function (a) { var i = this, e = a.currentTarget.dataset.joinid, {voteid}=a.currentTarget.dataset; this.setData({voteid}) t.getjoininfo(i, e); }, sendgift: function (a) { var i = this, e = a.currentTarget.dataset.joinid, o = a.currentTarget.dataset.giftid; t.sendgift(i, e, o); }, replybut: function (a) { var i = this, t = i.data.detail, e = i.data.reply; 1 == a.currentTarget.dataset.data ? (t.isreply = !0, e.length = 0) : t.isreply = !1, i.setData({ detail: t, reply: e }); }, replycontent: function (a) { var i = this, t = i.data.reply; t.content = a.detail.value, t.length = a.detail.value.length, i.setData({ reply: t }); }, reply: function (a) { var i = this, e = a.currentTarget.dataset.joinid, o = i.data.reply.content; i.data.reply.length < 1 || t.reply(i, e, o); }, giftbox: function () { var a = this; t.giftbox(a); }, vote: function (a) { var i = this, e = i.data.config.isgiftjoin; // if ("修改信息" != i.data.detail.font && 1 == e) { // console.log(2); // var o = i.data.index; // console.log(o); // return o.giftid = a.currentTarget.dataset.joinid, i.setData({ // index: o // }), void t.giftbox(i); // } var n = a.currentTarget.dataset.joinid; if (1 == a.currentTarget.dataset.topage) { t.vote(i, n); } else { i.data.showpage; "join", i.setData({ showpage: "join" }); } }, haibao: function (a) { var i = this, e = a.currentTarget.dataset.joinid; t.haibao(i, e); }, saveImg: function () { wx.downloadFile({ url: this.data.detail.imgurl, success: function (a) { var i = a.tempFilePath; wx.saveImageToPhotosAlbum({ filePath: i, success: function (a) { console.log(a); }, fail: function (a) { console.log(a); }, complete: function (a) { console.log(a); } }); }, fail: function (a) { console.log(a); } }); }, onSlideChangeEnd: function (a) { var i = this, t = i.data.detail; t.imgbg = a.detail.current, i.setData({ detail: t }) }, modalcnt: function () { wx.showModal({ title: "分享", content: "点击右上角的 ··· 转发给朋友哦~", success: function (a) { a.confirm ? console.log("用户点击确定") : a.cancel && console.log("用户点击取消"); } }); }, maximg: function (a) { console.log(a.target.dataset.img); var i = this, t = i.data.detail; t.maximg = a.target.dataset.img, t.maxpic = !0, i.setData({ detail: t }); }, maxpic: function (a) { var i = this, t = i.data.detail; t.maxpic = !1, i.setData({ detail: t }); }, videoshow: function (a) { var i = this, t = i.data.detail; "flex" == t.videoshow ? t.videoshow = "none" : "" == t.video ? wx.showToast({ title: "没有上传视频", icon: "succes", duration: 1e3, mask: !0 }) : t.videoshow = "flex", i.setData({ detail: t }); }, musicshow: function (a) { var i = this, t = i.data.detail; "music_off" != t.musicshow ? (wx.stopBackgroundAudio(), t.musicshow = "music_off", console.log(t.music)) : "" == t.music ? wx.showToast({ title: "没有上传音频", icon: "succes", duration: 1e3, mask: !0 }) : (t.musicshow = "music", console.log(t.music), wx.playBackgroundAudio({ dataUrl: t.music }), wx.onBackgroundAudioStop(function () { t.musicshow = "music_off", i.setData({ detail: t }); })), i.setData({ detail: t }); }, adindex: function (a) { var i = this, t = i.data.index; t.isadindex = !1, "0" != t.advote && t.adfixed != t.advote && (t.adfixed = t.advote), i.setData({ index: t }); }, timeFormat(param) { //小于10的格式化函数 return param < 10 ? '0' + param : param; }, countDown() { //倒计时函数 // 获取当前时间,同时得到活动结束时间数组 let newTime = new Date().getTime(); let endTimeList = [this.data.actEndTimeList]; let countDownArr = []; // 对结束时间进行处理渲染到页面 endTimeList.forEach(o => { let endTime = new Date(o).getTime(); let obj = null; // 如果活动未结束,对时间进行处理 if (endTime - newTime > 0) { let time = (endTime - newTime) / 1000; // 获取天、时、分、秒 let day = parseInt(time / (60 * 60 * 24)); let hou = parseInt(time % (60 * 60 * 24) / 3600); let min = parseInt(time % (60 * 60 * 24) % 3600 / 60); let sec = parseInt(time % (60 * 60 * 24) % 3600 % 60); obj = { day: this.timeFormat(day), hou: this.timeFormat(hou), min: this.timeFormat(min), sec: this.timeFormat(sec) } } else { //活动已结束,全部设置为'00' obj = { day: '00', hou: '00', min: '00', sec: '00' } } countDownArr.push(obj); }) // 渲染,然后每隔一秒执行一次倒计时函数 this.setData({ countDownList: countDownArr }) setTimeout(this.countDown, 1000); }, isIphoneX() { let info = wx.getSystemInfoSync(); console.log(/iPhone X/i.test(info.model)) if (/iPhone X/i.test(info.model)) { return true; } else { return false; } }, open() { this.setData({ ["config.open"]: true }) }, close() { this.setData({ ["config.open"]: false }) } });