抖音c端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

247 lines
6.2 KiB

  1. const navigationBarHeight = (getApp().statusBarHeight + 50) + 'px'
  2. const Http = require("../../../../utils/HttpBasics");
  3. const imgurl = require("../../../../utils/imgurl");
  4. const config = require("../../../../config/config");
  5. const util = require("../../../../utils/util");
  6. let app = getApp();
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. navigationBarHeight,
  13. noMerchant: imgurl.noMerchant.url,
  14. noCoupon: imgurl.noCoupon.url,
  15. poterbg: imgurl.poterbg.url,
  16. teljpgUrl: imgurl.teljpg.url,
  17. fenxiang: imgurl.fenxiang1.url,
  18. actUrl: imgurl.act.url,
  19. wmhome: imgurl.wmhome.url,
  20. page: 1,
  21. imglist: null,
  22. shopVoList: [],
  23. couponList: [], //活动劵列表
  24. qrCodeL: '', //小程序码
  25. currentTab: 0,
  26. isshare: false,
  27. showpost: false,
  28. imgHeight: 0,
  29. id: null,
  30. windowWidth: tt.getSystemInfoSync().windowWidth,
  31. windowHeight: tt.getSystemInfoSync().screenHeight,
  32. totalHeight: 0,
  33. canvasScale: 1.0, // 画布放大的倍数,因为如果保存的是一倍的分享图片的话,分享图会有点虚。所以保存的时候,canvasScale设置为2.0,wxss 里面的left: 500%;打开注释。就可保存两倍的分享图
  34. },
  35. //关闭海报
  36. closePoste: function() {
  37. this.setData({
  38. showpost: false
  39. })
  40. },
  41. goback: function () {
  42. tt.reLaunch({
  43. url: '/index/index',
  44. })
  45. },
  46. /**
  47. * 生命周期函数--监听页面加载
  48. */
  49. onLoad: function(options) {
  50. let that = this;
  51. if (options && options.id) {
  52. this.setData({
  53. id: options.id
  54. });
  55. that.getList(options.id);
  56. that.getCouponList(options.id);
  57. this.setData({
  58. currentTab: 0
  59. })
  60. }
  61. },
  62. /**
  63. * 拨打电话
  64. */
  65. phone: function(e) {
  66. let that = this;
  67. tt.makePhoneCall({
  68. phoneNumber: e.target.dataset.merchantlinkphone
  69. });
  70. },
  71. /**
  72. * 显示分享弹框
  73. */
  74. showshare: function() {
  75. this.setData({
  76. isshare: true,
  77. })
  78. },
  79. /**
  80. * 隐藏分享弹框
  81. */
  82. hidemodal: function() {
  83. this.setData({
  84. isshare: false,
  85. })
  86. },
  87. //滑动切换
  88. swiperTabView: function(e) {
  89. this.setData({
  90. currentTab: e.detail.current
  91. });
  92. },
  93. /**
  94. * 显示分享海报
  95. */
  96. /* showPoster: function() {
  97. //跳转到海报生成页
  98. tt.navigateTo({
  99. url: `/pages/canvas/index?merchantId=${this.data.id}`
  100. })
  101. }, */
  102. showPoster: function() {
  103. //跳转到海报生成页
  104. let that = this;
  105. Http.get({
  106. url: config.api.checkUserStatus,
  107. data: {
  108. token: app.globalData.token
  109. }
  110. }).then(res => {
  111. tt.navigateTo({
  112. url: `/pages/canvas/index?merchantId=${that.data.id}`
  113. })
  114. }).catch(err => {
  115. console.log(err)
  116. if (err.code == 11004) {
  117. // 用户昵称未授权
  118. tt.redirectTo({
  119. url: `/pages/getuserinfo/index?couponChannelId=${that.data.id}&fromflag=poster`
  120. })
  121. }
  122. })
  123. },
  124. //点击切换
  125. clickTab: function(e) {
  126. if (this.data.currentTab === e.target.dataset.current) {
  127. return false;
  128. } else {
  129. this.setData({
  130. currentTab: e.target.dataset.current
  131. })
  132. }
  133. },
  134. /**
  135. * 获取商户详情
  136. */
  137. getList: function(id) {
  138. let that = this;
  139. let data;
  140. data = {
  141. pageNum: that.data.page,
  142. pageSize: 15,
  143. id: id
  144. }
  145. Http.get({
  146. url: config.api.merchantList,
  147. data: data
  148. }).then(res => {
  149. if (res.data.list.length==0){
  150. tt.showModal({
  151. title: '提示',
  152. content: '此商户已经停用',
  153. confirmText: "返回",
  154. showCancel:false,
  155. success: function (res) {
  156. if (res.confirm) {
  157. tt.navigateBack({
  158. url: '/index/searchbar',
  159. })
  160. }
  161. }
  162. })
  163. }
  164. let imgList = [];
  165. imgList.push(res.data.list[0].merchantImgUrl)
  166. that.setData({
  167. data: res.data.list[0],
  168. shopVoList: res.data.list[0].shopVoList,
  169. imglist: res.data.list[0].coverPicture == '[]' ? imgList : JSON.parse(res.data.list[0].coverPicture),
  170. })
  171. })
  172. .catch(err => {
  173. tt.showToast({
  174. title: err.errMsg,
  175. icon: 'none',
  176. duration: 2000,
  177. mask: false
  178. });
  179. })
  180. },
  181. /**
  182. * 获取商户活动信息 券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券,6.多商户券,8.砍价券,9.团购券,50.积分券,51.积分停车券 100.消费卡)
  183. * 投放频道:(1.列表, 2.限时抢购, 3. banner图 4. 游戏 5.卡频道 6.砍价频道 7.拼团频道 8专题)
  184. */
  185. getCouponList: function(id) {
  186. let that = this;
  187. let data;
  188. data = {
  189. status: 0,
  190. merchantId: id,
  191. pageNum: that.data.page,
  192. pageSize: 15,
  193. }
  194. Http.post({
  195. url: config.api.listByMerchant,
  196. data: data
  197. }).then(res => {
  198. that.setData({
  199. couponList: res.data.page.list,
  200. })
  201. // if (res.data && res.data.qrCode){
  202. // that.setData({
  203. // qrCode: res.data.qrCode,
  204. // })
  205. // }
  206. })
  207. .catch(err => {
  208. tt.showToast({
  209. title: err.errMsg,
  210. icon: 'none',
  211. duration: 2000,
  212. mask: false
  213. });
  214. })
  215. },
  216. /**
  217. * 获取多商铺列表
  218. */
  219. onShareAppMessage: function(res) {
  220. app.globalData.previewFlag = true
  221. let that = this;
  222. let shareObj = {
  223. title: that.data.data.merchantName,
  224. path: `/pages/index/index?id=${that.data.id}&frommd=md&type=md`,
  225. success: function(res) {
  226. if (res.errMsg == 'shareAppMessage:ok') {}
  227. },
  228. fail: function(error) {
  229. if (res.errMsg == 'shareAppMessage:fail cancel') {} else if (res.errMsg == 'shareAppMessage:fail') {}
  230. }
  231. };
  232. console.log(`/pages/index/index?id=${that.data.id}&frommd=md`);
  233. // 来自页面内的按钮的转发
  234. if (res.from === 'button') {
  235. console.log(res)
  236. var eData = res.target.dataset.id;
  237. console.log(eData)
  238. shareObj.path = `/pages/index/index?id=${eData}&frommd=md&type=md`;
  239. }
  240. // 返回shareObj
  241. return shareObj;
  242. }
  243. })