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.7 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. return {
  99. title: _this.data.userName + '赠送您一张' + _this.data.cardDetail.title,
  100. imageUrl: _this.data.cardDetail.coverImg,
  101. 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}&tenantId=${_this.data.cardDetail.tenantId}`,
  102. success: function (res) {
  103. // 转发成功
  104. },
  105. fail: function (res) {
  106. // 转发失败
  107. }
  108. }
  109. } else {
  110. console.log(res, 444444444444444444)
  111. }
  112. },
  113. // 点击查看更多
  114. more: function () {
  115. let that = this;
  116. if (that.data.more == '点击查看更多') {
  117. this.setData({
  118. hidden: "",
  119. height: that.data.cardDetail.merchantVoList.length * 140 + 'rpx',
  120. more: "点击收起",
  121. showMore: true
  122. })
  123. }
  124. else {
  125. this.setData({
  126. hidden: "hidden",
  127. height: 4 * 140 + 'rpx',
  128. more: "点击查看更多",
  129. showMore: true
  130. })
  131. }
  132. },
  133. onLoad(options) {
  134. let that = this;
  135. if (options.cardId) {
  136. that.cardpayList(options.cardId);
  137. that.cardDetail(options.cardId);
  138. }
  139. if (options.from) {
  140. this.setData({
  141. showIndexReuturn: true
  142. })
  143. }
  144. wx.hideShareMenu()
  145. },
  146. cardpayList: function (cardId) {
  147. let that = this;
  148. wx.showLoading({
  149. title: "加载中..."
  150. });
  151. var parmer = {
  152. url: config.api.cardpayList,
  153. data: {
  154. cardId: cardId,
  155. pageNum: 1,
  156. pageSize: 100
  157. }
  158. };
  159. Http.get(parmer)
  160. .then(res => {
  161. console.log(res);
  162. if (res.code == 200 && res.data.list.length > 0) {
  163. that.setData({
  164. showPage: true
  165. })
  166. } else { }
  167. wx.hideLoading();
  168. res.data.list.map(file => {
  169. file.updateDate = util.formatTime(file.updateDate, "yyyy-MM-dd hh:mm:ss")
  170. })
  171. that.setData({
  172. data: res.data.list
  173. });
  174. }).catch(err => {
  175. wx.showToast({
  176. title: err.message,
  177. icon: 'none',
  178. duration: 2000,
  179. mask: false
  180. });
  181. })
  182. },
  183. getUserInfo: function () {
  184. let that = this;
  185. // 获取用户信息
  186. Http.get({
  187. url: config.api.getScore,
  188. data: {}
  189. })
  190. .then(res => {
  191. console.log(res)
  192. that.setData({
  193. userName: res.data.nickName,
  194. avatarUrl: res.data.avatarUrl
  195. })
  196. })
  197. },
  198. cardDetail: function (couponOrderId) {
  199. let that = this;
  200. Http.get({
  201. url: config.api.cardDetail,
  202. data: {
  203. couponOrderId: couponOrderId
  204. }
  205. })
  206. .then(res => {
  207. console.log(res)
  208. if (res.code == 200) {
  209. res.data.expiredTime = util.formatTime(res.data.expiredTime, "yyyy-MM-dd hh:mm:ss")
  210. that.setData({
  211. showPage: true,
  212. cardDetail: res.data,
  213. supportTransfer: res.data.supportTransfer
  214. })
  215. /**
  216. * 若可转赠获取用户头像信息
  217. */
  218. if (res.data.supportTransfer) {
  219. that.getUserInfo()
  220. }
  221. if (that.data.cardDetail.merchantVoList && that.data.cardDetail.merchantVoList.length <= 4) {
  222. that.setData({
  223. height: that.data.cardDetail.merchantVoList.length * 140 + 'rpx',
  224. showMore: false
  225. })
  226. } else if (that.data.cardDetail.merchantVoList && that.data.cardDetail.merchantVoList.length > 4) {
  227. that.setData({
  228. height: 4 * 140 + 'rpx'
  229. })
  230. }
  231. }
  232. })
  233. .catch(err => {
  234. console.log(err)
  235. })
  236. },
  237. onShow() {
  238. let that = this;
  239. that.setData({
  240. showbutton: false
  241. })
  242. },
  243. });