C端小程序
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

253 行
6.9 KiB

  1. const navigationBarHeight = (getApp().statusBarHeight + 44) + 'px';
  2. var config = require("../../config/config.js");
  3. var app = getApp();
  4. const Http = require("../../utils/HttpBasics");
  5. const util = require("../../utils/util");
  6. const imgurl = require("../../utils/imgurl");
  7. Page({
  8. data: {
  9. navigationBarHeight,
  10. fenxiangUrl: imgurl.fenxiang.url,
  11. clockUrl: imgurl.clock.url,
  12. teljpgUrl: imgurl.teljpg.url,
  13. closedUrl: imgurl.closed.url,
  14. quesGouUrl: imgurl.ques_gou.url,
  15. headbgUrl: imgurl.headbg.url,
  16. quesBgUrl: imgurl.ques_bg.url,
  17. dingdanUrl: imgurl.dingdan.url,
  18. weixinTitle: imgurl.weixinTitle.url,
  19. home: imgurl.home.url,
  20. cardDetail: null,
  21. data: {
  22. title: null
  23. },
  24. showPage: false,
  25. questions1: null,
  26. questions2: null,
  27. carList: [],
  28. couponChannelId: null,
  29. couponId: null,
  30. orderId: "",
  31. hour: null,
  32. minute: "",
  33. tempFilePaths: null,
  34. userInfo: {},
  35. hasUserInfo: false,
  36. canIUse: wx.canIUse('button.open-type.getUserInfo'),
  37. id: null,
  38. result: [],
  39. end_time: null,
  40. checked: false,
  41. clock: "已经截止",
  42. questionnaire: {},
  43. questionId: null,
  44. widthScreen: null,
  45. moveData: null,
  46. rotateData: null,
  47. alphaData: null,
  48. scaleData: null,
  49. skewData: null,
  50. matrixData: null,
  51. opacity: 0,
  52. queueData: null,
  53. zIndex: 11,
  54. display: "none",
  55. showbutton: false,
  56. hidden: "hidden",
  57. height: "",
  58. more: "点击查看更多",
  59. showMore: true,
  60. supportTransfer: 1,
  61. showIndexReuturn: false
  62. },
  63. phone: function (e) {
  64. let that = this;
  65. wx.makePhoneCall({
  66. phoneNumber: e.target.dataset.merchantlinkphone
  67. });
  68. },
  69. /**
  70. * 跳转到门店列表的详情页面
  71. */
  72. gotoDetail(e) {
  73. if (e.currentTarget.dataset.id == undefined) {
  74. return
  75. }
  76. wx.navigateTo({
  77. url: `/pages/index/searchbar/detail/index?id=${e.currentTarget.dataset.id}`
  78. })
  79. },
  80. gotoIndex() {
  81. wx.navigateTo({
  82. url: '/pages/index/index',
  83. })
  84. },
  85. goToTranser() {
  86. this.onShareAppMessage();
  87. // wx.navigateTo({
  88. // url: '/pages/index/index?couponChannelId=316424281708658688&cuserId=316369316574887936&couponId=316424281708658688&coverImg=https://iformall-net.s3.cn-northwest-1.amazonaws.com.cn/456/90d50e2d-547c-43e1-a801-2f6e15f622d2.jpg&userName=轻泉漪溪&avatarUrl=https://wx.qlogo.cn/mmopen/vi_32/oibIKqnzXT21eZJdjKVKY91A36FqLbD3ibEFc2oxIC4iahLniccDQKVu1Tgp4kJupxRZjtEpW0ravJ9QW1HuncGVjA/132&couponOrderId=316424688259530752&updateDate=1564553135000',
  89. // })
  90. },
  91. onShareAppMessage: function (res) {
  92. let _this = this;
  93. console.log(_this.data, '_this');
  94. app.globalData.previewFlag = true
  95. if (res.from === 'button') {
  96. console.log(this.data.cardDetail)
  97. // 来自页面内转发按钮
  98. const restData = JSON.stringify({
  99. coverImg: _this.data.cardDetail.coverImg,
  100. avatarUrl: _this.data.avatarUrl,
  101. couponOrderId: _this.data.cardDetail.id,
  102. updateDate: _this.data.cardDetail.updateDate
  103. })
  104. return {
  105. title: _this.data.userName + '赠送您一张' + _this.data.cardDetail.title,
  106. imageUrl: _this.data.cardDetail.coverImg,
  107. path: `/pages/index/index?couponChannelId=${_this.data.cardDetail.couponChannelId}&avatarUrl=${_this.data.cardDetail.avatarUrl}&cuserId=${_this.data.cardDetail.ownerId}&userName=${_this.data.userName}&couponId=${_this.data.cardDetail.couponId}&couponOrderId=${_this.data.cardDetail.id}&updateDate=${_this.data.cardDetail.updateDate}&coverImg=${_this.data.cardDetail.coverImg}`,
  108. success: function (res) {
  109. // 转发成功
  110. },
  111. fail: function (res) {
  112. // 转发失败
  113. }
  114. }
  115. } else {
  116. console.log(res, 444444444444444444)
  117. }
  118. },
  119. // 点击查看更多
  120. more: function () {
  121. let that = this;
  122. if (that.data.more == '点击查看更多') {
  123. this.setData({
  124. hidden: "",
  125. height: that.data.cardDetail.merchantVoList.length * 140 + 'rpx',
  126. more: "点击收起",
  127. showMore: true
  128. })
  129. }
  130. else {
  131. this.setData({
  132. hidden: "hidden",
  133. height: 4 * 140 + 'rpx',
  134. more: "点击查看更多",
  135. showMore: true
  136. })
  137. }
  138. },
  139. onLoad(options) {
  140. let that = this;
  141. if (options.cardId) {
  142. that.cardpayList(options.cardId);
  143. that.cardDetail(options.cardId);
  144. }
  145. if (options.from) {
  146. this.setData({
  147. showIndexReuturn: true
  148. })
  149. }
  150. wx.hideShareMenu()
  151. },
  152. cardpayList: function (cardId) {
  153. let that = this;
  154. wx.showLoading({
  155. title: "加载中..."
  156. });
  157. var parmer = {
  158. url: config.api.cardpayList,
  159. data: {
  160. cardId: cardId,
  161. pageNum: 1,
  162. pageSize: 100
  163. }
  164. };
  165. Http.get(parmer)
  166. .then(res => {
  167. console.log(res);
  168. if (res.code == 200 && res.data.list.length > 0) {
  169. that.setData({
  170. showPage: true
  171. })
  172. } else { }
  173. wx.hideLoading();
  174. res.data.list.map(file => {
  175. file.updateDate = util.formatTime(file.updateDate, "yyyy-MM-dd hh:mm:ss")
  176. })
  177. that.setData({
  178. data: res.data.list
  179. });
  180. }).catch(err => {
  181. wx.showToast({
  182. title: err.message,
  183. icon: 'none',
  184. duration: 2000,
  185. mask: false
  186. });
  187. })
  188. },
  189. getUserInfo: function () {
  190. let that = this;
  191. // 获取用户信息
  192. Http.get({
  193. url: config.api.getScore,
  194. data: {}
  195. })
  196. .then(res => {
  197. console.log(res)
  198. that.setData({
  199. userName: res.data.nickName,
  200. avatarUrl: res.data.avatarUrl
  201. })
  202. })
  203. },
  204. cardDetail: function (couponOrderId) {
  205. let that = this;
  206. Http.get({
  207. url: config.api.cardDetail,
  208. data: {
  209. couponOrderId: couponOrderId
  210. }
  211. })
  212. .then(res => {
  213. console.log(res)
  214. if (res.code == 200) {
  215. res.data.expiredTime = util.formatTime(res.data.expiredTime, "yyyy-MM-dd hh:mm:ss")
  216. that.setData({
  217. showPage: true,
  218. cardDetail: res.data,
  219. supportTransfer: res.data.supportTransfer
  220. })
  221. /**
  222. * 若可转赠获取用户头像信息
  223. */
  224. if (res.data.supportTransfer) {
  225. that.getUserInfo()
  226. }
  227. if (that.data.cardDetail.merchantVoList && that.data.cardDetail.merchantVoList.length <= 4) {
  228. that.setData({
  229. height: that.data.cardDetail.merchantVoList.length * 140 + 'rpx',
  230. showMore: false
  231. })
  232. } else if (that.data.cardDetail.merchantVoList && that.data.cardDetail.merchantVoList.length > 4) {
  233. that.setData({
  234. height: 4 * 140 + 'rpx'
  235. })
  236. }
  237. }
  238. })
  239. .catch(err => {
  240. console.log(err)
  241. })
  242. },
  243. onShow() {
  244. let that = this;
  245. that.setData({
  246. showbutton: false
  247. })
  248. },
  249. });