抖音c端
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

249 řádky
6.3 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, options.mallTenantId);
  56. that.getCouponList(options.id, options.mallTenantId);
  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, mallTenantId) {
  138. let that = this;
  139. let data;
  140. data = {
  141. pageNum: that.data.page,
  142. pageSize: 15,
  143. id: id,
  144. mallTenantId: mallTenantId
  145. }
  146. Http.get({
  147. url: config.api.merchantList,
  148. data: data
  149. }).then(res => {
  150. if (res.data.list.length == 0) {
  151. tt.showModal({
  152. title: '提示',
  153. content: '此商户已经停用',
  154. confirmText: "返回",
  155. showCancel: false,
  156. success: function (res) {
  157. if (res.confirm) {
  158. tt.navigateBack({
  159. url: '/index/searchbar',
  160. })
  161. }
  162. }
  163. })
  164. }
  165. let imgList = [];
  166. imgList.push(res.data.list[0].merchantImgUrl)
  167. that.setData({
  168. data: res.data.list[0],
  169. shopVoList: res.data.list[0].shopVoList,
  170. imglist: res.data.list[0].coverPicture == '[]' ? imgList : JSON.parse(res.data.list[0].coverPicture),
  171. })
  172. })
  173. .catch(err => {
  174. tt.showToast({
  175. title: err.errMsg,
  176. icon: 'none',
  177. duration: 2000,
  178. mask: false
  179. });
  180. })
  181. },
  182. /**
  183. * 获取商户活动信息 券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券,6.多商户券,8.砍价券,9.团购券,50.积分券,51.积分停车券 100.消费卡)
  184. * 投放频道:(1.列表, 2.限时抢购, 3. banner图 4. 游戏 5.卡频道 6.砍价频道 7.拼团频道 8专题)
  185. */
  186. getCouponList: function (id, mallTenantId) {
  187. let that = this;
  188. let data;
  189. data = {
  190. status: 0,
  191. merchantId: id,
  192. pageNum: that.data.page,
  193. pageSize: 15,
  194. mallTenantId: mallTenantId
  195. }
  196. Http.post({
  197. url: config.api.listByMerchant,
  198. data: data
  199. }).then(res => {
  200. that.setData({
  201. couponList: res.data.page.list,
  202. })
  203. // if (res.data && res.data.qrCode){
  204. // that.setData({
  205. // qrCode: res.data.qrCode,
  206. // })
  207. // }
  208. })
  209. .catch(err => {
  210. tt.showToast({
  211. title: err.errMsg,
  212. icon: 'none',
  213. duration: 2000,
  214. mask: false
  215. });
  216. })
  217. },
  218. /**
  219. * 获取多商铺列表
  220. */
  221. onShareAppMessage: function (res) {
  222. app.globalData.previewFlag = true
  223. let that = this;
  224. let shareObj = {
  225. title: that.data.data.merchantName,
  226. path: `/pages/index/index?id=${that.data.id}&frommd=md&type=md`,
  227. success: function (res) {
  228. if (res.errMsg == 'shareAppMessage:ok') {}
  229. },
  230. fail: function (error) {
  231. if (res.errMsg == 'shareAppMessage:fail cancel') {} else if (res.errMsg == 'shareAppMessage:fail') {}
  232. }
  233. };
  234. console.log(`/pages/index/index?id=${that.data.id}&frommd=md`);
  235. // 来自页面内的按钮的转发
  236. if (res.from === 'button') {
  237. console.log(res)
  238. var eData = res.target.dataset.id;
  239. console.log(eData)
  240. shareObj.path = `/pages/index/index?id=${eData}&frommd=md&type=md`;
  241. }
  242. // 返回shareObj
  243. return shareObj;
  244. }
  245. })