抖音c端
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

259 wiersze
6.6 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. console.log(options, 'options');
  51. let that = this;
  52. if (options && options.id) {
  53. this.setData({
  54. id: options.id
  55. });
  56. const tenantId = options.tenantId
  57. if (tenantId) {
  58. that.getList(options.id, tenantId);
  59. that.getCouponList(options.id, tenantId);
  60. tt.setStorageSync('mallTenantId', tenantId);
  61. } else {
  62. that.getList(options.id, options.mallTenantId);
  63. that.getCouponList(options.id, options.mallTenantId);
  64. }
  65. this.setData({
  66. currentTab: 0
  67. })
  68. }
  69. },
  70. /**
  71. * 拨打电话
  72. */
  73. phone: function (e) {
  74. let that = this;
  75. tt.makePhoneCall({
  76. phoneNumber: e.target.dataset.merchantlinkphone
  77. });
  78. },
  79. /**
  80. * 显示分享弹框
  81. */
  82. showshare: function () {
  83. this.setData({
  84. isshare: true,
  85. })
  86. },
  87. /**
  88. * 隐藏分享弹框
  89. */
  90. hidemodal: function () {
  91. this.setData({
  92. isshare: false,
  93. })
  94. },
  95. //滑动切换
  96. swiperTabView: function (e) {
  97. this.setData({
  98. currentTab: e.detail.current
  99. });
  100. },
  101. /**
  102. * 显示分享海报
  103. */
  104. /* showPoster: function() {
  105. //跳转到海报生成页
  106. tt.navigateTo({
  107. url: `/pages/canvas/index?merchantId=${this.data.id}`
  108. })
  109. }, */
  110. showPoster: function () {
  111. //跳转到海报生成页
  112. let that = this;
  113. Http.get({
  114. url: config.api.checkUserStatus,
  115. data: {
  116. token: app.globalData.token
  117. }
  118. }).then(res => {
  119. tt.navigateTo({
  120. url: `/pages/canvas/index?merchantId=${that.data.id}`
  121. })
  122. }).catch(err => {
  123. console.log(err)
  124. if (err.code == 11004) {
  125. // 用户昵称未授权
  126. tt.redirectTo({
  127. url: `/pages/getuserinfo/index?couponChannelId=${that.data.id}&fromflag=poster`
  128. })
  129. }
  130. })
  131. },
  132. //点击切换
  133. clickTab: function (e) {
  134. if (this.data.currentTab === e.target.dataset.current) {
  135. return false;
  136. } else {
  137. this.setData({
  138. currentTab: e.target.dataset.current
  139. })
  140. }
  141. },
  142. /**
  143. * 获取商户详情
  144. */
  145. getList: function (id, mallTenantId) {
  146. let that = this;
  147. let data;
  148. data = {
  149. pageNum: that.data.page,
  150. pageSize: 15,
  151. id: id,
  152. mallTenantId: mallTenantId
  153. }
  154. Http.get({
  155. url: config.api.merchantList,
  156. data: data
  157. }).then(res => {
  158. if (res.data.list.length == 0) {
  159. tt.showModal({
  160. title: '提示',
  161. content: '此商户已经停用',
  162. confirmText: "返回",
  163. showCancel: false,
  164. success: function (res) {
  165. if (res.confirm) {
  166. tt.navigateBack({
  167. url: '/index/searchbar',
  168. })
  169. }
  170. }
  171. })
  172. }
  173. let imgList = [];
  174. imgList.push(res.data.list[0].merchantImgUrl)
  175. that.setData({
  176. data: res.data.list[0],
  177. shopVoList: res.data.list[0].shopVoList,
  178. imglist: res.data.list[0].coverPicture == '[]' ? imgList : JSON.parse(res.data.list[0].coverPicture),
  179. })
  180. })
  181. .catch(err => {
  182. tt.showToast({
  183. title: err.errMsg,
  184. icon: 'none',
  185. duration: 2000,
  186. mask: false
  187. });
  188. })
  189. },
  190. /**
  191. * 获取商户活动信息 券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券,6.多商户券,8.砍价券,9.团购券,50.积分券,51.积分停车券 100.消费卡)
  192. * 投放频道:(1.列表, 2.限时抢购, 3. banner图 4. 游戏 5.卡频道 6.砍价频道 7.拼团频道 8专题)
  193. */
  194. getCouponList: function (id, mallTenantId) {
  195. let that = this;
  196. let data;
  197. data = {
  198. status: 0,
  199. merchantId: id,
  200. pageNum: that.data.page,
  201. pageSize: 15,
  202. mallTenantId: mallTenantId
  203. }
  204. Http.post({
  205. url: config.api.listByMerchant,
  206. data: data
  207. }).then(res => {
  208. console.log(res, 'res');
  209. that.setData({
  210. couponList: res.data.page.list,
  211. })
  212. // if (res.data && res.data.qrCode){
  213. // that.setData({
  214. // qrCode: res.data.qrCode,
  215. // })
  216. // }
  217. })
  218. .catch(err => {
  219. tt.showToast({
  220. title: err.errMsg,
  221. icon: 'none',
  222. duration: 2000,
  223. mask: false
  224. });
  225. })
  226. },
  227. /**
  228. * 获取多商铺列表
  229. */
  230. onShareAppMessage: function (res) {
  231. app.globalData.previewFlag = true
  232. let that = this;
  233. let shareObj = {
  234. title: that.data.data.merchantName,
  235. path: `/pages/index/index?id=${that.data.id}&frommd=md&type=md`,
  236. success: function (res) {
  237. if (res.errMsg == 'shareAppMessage:ok') {}
  238. },
  239. fail: function (error) {
  240. if (res.errMsg == 'shareAppMessage:fail cancel') {} else if (res.errMsg == 'shareAppMessage:fail') {}
  241. }
  242. };
  243. console.log(`/pages/index/index?id=${that.data.id}&frommd=md`);
  244. // 来自页面内的按钮的转发
  245. if (res.from === 'button') {
  246. console.log(res)
  247. var eData = res.target.dataset.id;
  248. console.log(eData)
  249. shareObj.path = `/pages/index/index?id=${eData}&frommd=md&type=md`;
  250. }
  251. // 返回shareObj
  252. return shareObj;
  253. }
  254. })