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.

253 line
6.8 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. pageNum: 1
  63. },
  64. phone: function (e) {
  65. let that = this;
  66. wx.makePhoneCall({
  67. phoneNumber: e.target.dataset.merchantlinkphone
  68. });
  69. },
  70. /**
  71. * 跳转到门店列表的详情页面
  72. */
  73. gotoDetail(e) {
  74. if (e.currentTarget.dataset.id == undefined) {
  75. return
  76. }
  77. wx.navigateTo({
  78. url: `/pages/index/searchbar/detail/index?id=${e.currentTarget.dataset.id}`
  79. })
  80. },
  81. gotoIndex() {
  82. wx.navigateTo({
  83. url: '/pages/index/index',
  84. })
  85. },
  86. goToTranser() {
  87. this.onShareAppMessage();
  88. // wx.navigateTo({
  89. // 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',
  90. // })
  91. },
  92. onShareAppMessage: function (res) {
  93. let _this = this;
  94. console.log(_this.data, '_this');
  95. app.globalData.previewFlag = true
  96. if (res.from === 'button') {
  97. console.log(this.data.cardDetail)
  98. // 来自页面内转发按钮
  99. return {
  100. title: _this.data.userName + '赠送您一张' + _this.data.cardDetail.title,
  101. imageUrl: _this.data.cardDetail.coverImg,
  102. 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}`,
  103. success: function (res) {
  104. // 转发成功
  105. },
  106. fail: function (res) {
  107. // 转发失败
  108. }
  109. }
  110. } else {
  111. console.log(res, 444444444444444444)
  112. }
  113. },
  114. // 点击查看更多
  115. more: function () {
  116. let that = this;
  117. if (that.data.more == '点击查看更多') {
  118. this.setData({
  119. hidden: "",
  120. height: that.data.cardDetail.merchantVoList.length * 140 + 'rpx',
  121. more: "点击收起",
  122. showMore: true
  123. })
  124. }
  125. else {
  126. this.setData({
  127. hidden: "hidden",
  128. height: 4 * 140 + 'rpx',
  129. more: "点击查看更多",
  130. showMore: true
  131. })
  132. }
  133. },
  134. onLoad(options) {
  135. let that = this;
  136. if (options.cardId) {
  137. that.cardpayList(options.cardId);
  138. that.cardDetail(options.cardId);
  139. }
  140. if (options.from) {
  141. this.setData({
  142. showIndexReuturn: true
  143. })
  144. }
  145. wx.hideShareMenu()
  146. },
  147. cardpayList: function (cardId) {
  148. let that = this;
  149. wx.showLoading({
  150. title: "加载中..."
  151. });
  152. var parmer = {
  153. url: config.api.cardpayList,
  154. data: {
  155. cardId: cardId,
  156. pageNum: 1,
  157. pageSize: 500
  158. }
  159. };
  160. Http.get(parmer)
  161. .then(res => {
  162. console.log(res);
  163. if (res.code == 200 && res.data.list && res.data.list.length > 0) {
  164. wx.hideLoading();
  165. res.data.list.map(file => {
  166. file.updateDate = util.formatTime(file.updateDate, "yyyy-MM-dd hh:mm:ss")
  167. })
  168. that.setData({
  169. showPage: true,
  170. data: res.data.list
  171. })
  172. } else {
  173. wx.hideLoading();
  174. }
  175. }).catch(err => {
  176. console.log(err, 'err');
  177. wx.showToast({
  178. title: err.message,
  179. icon: 'none',
  180. duration: 2000,
  181. mask: false
  182. });
  183. })
  184. },
  185. getUserInfo: function () {
  186. let that = this;
  187. // 获取用户信息
  188. Http.get({
  189. url: config.api.getScore,
  190. data: {}
  191. })
  192. .then(res => {
  193. console.log(res)
  194. that.setData({
  195. userName: res.data.nickName,
  196. avatarUrl: res.data.avatarUrl
  197. })
  198. })
  199. },
  200. cardDetail: function (couponOrderId) {
  201. let that = this;
  202. Http.get({
  203. url: config.api.cardDetail,
  204. data: {
  205. couponOrderId: couponOrderId
  206. }
  207. })
  208. .then(res => {
  209. console.log(res)
  210. if (res.code == 200) {
  211. res.data.expiredTime = util.formatTime(res.data.expiredTime, "yyyy-MM-dd hh:mm:ss")
  212. that.setData({
  213. showPage: true,
  214. cardDetail: res.data,
  215. supportTransfer: res.data.supportTransfer
  216. })
  217. /**
  218. * 若可转赠获取用户头像信息
  219. */
  220. if (res.data.supportTransfer) {
  221. that.getUserInfo()
  222. }
  223. if (that.data.cardDetail.merchantVoList && that.data.cardDetail.merchantVoList.length <= 4) {
  224. that.setData({
  225. height: that.data.cardDetail.merchantVoList.length * 140 + 'rpx',
  226. showMore: false
  227. })
  228. } else if (that.data.cardDetail.merchantVoList && that.data.cardDetail.merchantVoList.length > 4) {
  229. that.setData({
  230. height: 4 * 140 + 'rpx'
  231. })
  232. }
  233. }
  234. })
  235. .catch(err => {
  236. console.log(err)
  237. })
  238. },
  239. onShow() {
  240. let that = this;
  241. that.setData({
  242. showbutton: false
  243. })
  244. },
  245. onReachBottom() {
  246. },
  247. });