|
- const Http = require("../../../../utils/HttpBasics");
- const imgurl = require("../../../../utils/imgurl");
- const config = require("../../../../config/config");
- let app = getApp();
- Page({
-
- /**
- * 页面的初始数据
- */
- data: {
- teljpgUrl: imgurl.teljpg.url,
- share01: imgurl.share01.url,
- page: 1,
- imglist: null,
- shopVoList: [],
- couponList: [], //活动劵列表
- data: {
- currentTab: 0
- },
- id: null
- },
-
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function(options) {
- let that = this;
- if (options && options.id) {
- this.setData({
- id: options.id
- });
- that.getList(options.id);
- that.getCouponList(options.id);
- }
- },
- /**
- * 拨打电话
- */
- phone: function(e) {
- let that = this;
- wx.makePhoneCall({
- phoneNumber: e.target.dataset.merchantlinkphone
- });
- },
- /**
- * 获取商户详情
- */
- getList: function(id) {
- let that = this;
- let data;
- data = {
- pageNum: that.data.page,
- pageSize: 15,
- id: id
- }
- Http.get({
- url: config.api.merchantList,
- data: data
- }).then(res => {
- that.setData({
- data: res.data.list[0],
- shopVoList: res.data.list[0].shopVoList,
- imglist: JSON.parse(res.data.list[0].coverPicture) ? JSON.parse(res.data.list[0].coverPicture) : res.data.list[0].merchantImgUrl,
- })
- })
- .catch(err => {
- wx.showToast({
- title: err.errMsg,
- icon: 'none',
- duration: 2000,
- mask: false
- });
- })
- },
- /**
- * 获取商户活动信息 券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券,6.多商户券,8.砍价券,9.团购券,50.积分券,51.积分停车券 100.消费卡)
- * 投放频道:(1.列表, 2.限时抢购, 3. banner图 4. 游戏 5.卡频道 6.砍价频道 7.拼团频道 8专题)
- */
- getCouponList: function(id) {
- let that = this;
- let data;
- data = {
- status: 0,
- merchantId: id,
- pageNum: that.data.page,
- pageSize: 15,
- }
- Http.get({
- url: config.api.merchantCouponList,
- data: data
- }).then(res => {
- that.setData({
- couponList: res.data.list,
- })
- })
- .catch(err => {
- wx.showToast({
- title: err.errMsg,
- icon: 'none',
- duration: 2000,
- mask: false
- });
- })
- },
-
- /**
- * 获取多商铺列表
- */
- shopList: function(e) {
- wx.navigateTo({
- url: `/pages/index/merchantList/index?id=${e.currentTarget.dataset.id}`
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function() {
-
- },
- onShareAppMessage: function(options) {
- var that = this;
- var shareObj = {
- title: that.data.data.title,
- path: `/pages/index/index?couponChannelId=${that.data.couponChannelId}`,
- success: function(res) {
- if (res.errMsg == 'shareAppMessage:ok') {}
- },
- fail: function(error) {
- if (res.errMsg == 'shareAppMessage:fail cancel') {} else if (res.errMsg == 'shareAppMessage:fail') {}
- }
- };
- // 来自页面内的按钮的转发
- if (options.from == 'button') {
- var eData = options.target.dataset.id;
- shareObj.path = `/pages/index/index?couponChannelId=${eData}`;
- }
- // 返回shareObj
- return shareObj;
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function() {
-
- },
- })
|