C端小程序
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

208 lines
5.4 KiB

  1. var config = require("../../config/config.js");
  2. var app = getApp();
  3. const Http = require("../../utils/HttpBasics");
  4. const util = require("../../utils/util");
  5. const imgurl = require("../../utils/imgurl");
  6. Page({
  7. data: {
  8. fenxiangUrl: imgurl.fenxiang.url,
  9. clockUrl: imgurl.clock.url,
  10. teljpgUrl: imgurl.teljpg.url,
  11. closedUrl: imgurl.closed.url,
  12. quesGouUrl: imgurl.ques_gou.url,
  13. headbgUrl: imgurl.headbg.url,
  14. quesBgUrl: imgurl.ques_bg.url,
  15. dingdanUrl: imgurl.dingdan.url,
  16. weixinTitle: imgurl.weixinTitle.url,
  17. cardDetail: null,
  18. data: {
  19. title: null
  20. },
  21. showPage: false,
  22. questions1: null,
  23. questions2: null,
  24. carList: [],
  25. couponChannelId: null,
  26. couponId: null,
  27. orderId: "",
  28. hour: null,
  29. minute: "",
  30. tempFilePaths: null,
  31. userInfo: {},
  32. hasUserInfo: false,
  33. canIUse: wx.canIUse('button.open-type.getUserInfo'),
  34. id: null,
  35. result: [],
  36. end_time: null,
  37. checked: false,
  38. clock: "已经截止",
  39. questionnaire: {},
  40. questionId: null,
  41. widthScreen: null,
  42. moveData: null,
  43. rotateData: null,
  44. alphaData: null,
  45. scaleData: null,
  46. skewData: null,
  47. matrixData: null,
  48. opacity: 0,
  49. queueData: null,
  50. zIndex: 11,
  51. display: "none",
  52. showbutton: false,
  53. hidden: "hidden",
  54. height: "",
  55. more: "点击查看更多",
  56. showMore: true,
  57. supportTransfer:1
  58. },
  59. phone: function(e) {
  60. let that = this;
  61. wx.makePhoneCall({
  62. phoneNumber: e.target.dataset.merchantlinkphone
  63. });
  64. },
  65. goToTranser(){
  66. this.onShareAppMessage();
  67. // wx.navigateTo({
  68. // url: '/pages/index/index?couponChannelId=' + this.data.cardDetail.couponChannelId + '&cuserId=' + this.data.cardDetail.cuserId + '&couponId=' + this.data.cardDetail.couponId,
  69. // })
  70. },
  71. onShareAppMessage: function (res) {
  72. let _this = this;
  73. return {
  74. title: '领取卡',
  75. path: '/pages/index/index?couponChannelId=' + this.data.cardDetail.couponChannelId + '&cuserId=' + this.data.cardDetail.cuserId + '&couponId=' + this.data.cardDetail.couponId + '&coverImg=' + this.data.cardDetail.coverImg + '&userName=' + this.data.userName + '&avatarUrl=' + this.data.avatarUrl + '&couponOrderId=' + this.data.cardDetail.id,
  76. imageUrl: this.data.cardDetail.coverImg,
  77. success: function (res) {
  78. // 转发成功
  79. },
  80. fail: function (res) {
  81. // 转发失败
  82. }
  83. }
  84. },
  85. // 点击查看更多
  86. more: function() {
  87. let that = this;
  88. if (that.data.more == '点击查看更多') {
  89. this.setData({
  90. hidden: "",
  91. height: that.data.cardDetail.merchantVoList.length * 140 + 'rpx',
  92. more: "点击收起",
  93. showMore: true
  94. })
  95. }
  96. else {
  97. this.setData({
  98. hidden: "hidden",
  99. height: 4* 140 + 'rpx',
  100. more: "点击查看更多",
  101. showMore: true
  102. })
  103. }
  104. },
  105. onLoad(options) {
  106. let that = this;
  107. console.log(options.cardId)
  108. that.cardpayList(options.cardId);
  109. that.cardDetail(options.cardId);
  110. },
  111. cardpayList: function(cardId) {
  112. let that = this;
  113. wx.showLoading({
  114. title: "加载中..."
  115. });
  116. var parmer = {
  117. url: config.api.cardpayList,
  118. data: {
  119. cardId: cardId,
  120. pageNum: 1,
  121. pageSize: 100
  122. }
  123. };
  124. Http.get(parmer)
  125. .then(res => {
  126. console.log(res);
  127. if (res.code == 200 && res.data.list.length > 0) {
  128. that.setData({
  129. showPage: true
  130. })
  131. } else {}
  132. wx.hideLoading();
  133. res.data.list.map(file => {
  134. file.updateDate = util.formatTime(file.updateDate, "yyyy-MM-dd hh:mm:ss")
  135. })
  136. that.setData({
  137. data: res.data.list
  138. });
  139. }).catch(err => {
  140. wx.showToast({
  141. title: err.message,
  142. icon: 'none',
  143. duration: 2000,
  144. mask: false
  145. });
  146. })
  147. },
  148. getUserInfo: function () {
  149. let that = this;
  150. // 获取用户信息
  151. Http.get({
  152. url: config.api.getScore,
  153. data: {}
  154. })
  155. .then(res => {
  156. console.log(res)
  157. that.setData({
  158. userName: res.data.nickName,
  159. avatarUrl: res.data.avatarUrl
  160. })
  161. })
  162. },
  163. cardDetail: function(couponOrderId) {
  164. let that = this;
  165. Http.get({
  166. url: config.api.cardDetail,
  167. data: {
  168. couponOrderId: couponOrderId
  169. }
  170. })
  171. .then(res => {
  172. console.log(res)
  173. if (res.code == 200) {
  174. res.data.expiredTime = util.formatTime(res.data.expiredTime, "yyyy-MM-dd hh:mm:ss")
  175. that.setData({
  176. showPage: true,
  177. cardDetail: res.data,
  178. supportTransfer: res.data.supportTransfer
  179. })
  180. /**
  181. * 若可转赠获取用户头像信息
  182. */
  183. if (res.data.supportTransfer){
  184. that.getUserInfo()
  185. }
  186. if (that.data.cardDetail.merchantVoList && that.data.cardDetail.merchantVoList.length<=4){
  187. that.setData({
  188. height: that.data.cardDetail.merchantVoList.length * 140 + 'rpx',
  189. showMore:false
  190. })
  191. } else if (that.data.cardDetail.merchantVoList && that.data.cardDetail.merchantVoList.length > 4){
  192. that.setData({
  193. height: 4 * 140 + 'rpx'
  194. })
  195. }
  196. }
  197. })
  198. .catch(err => {
  199. console.log(err)
  200. })
  201. },
  202. onShow() {
  203. let that = this;
  204. that.setData({
  205. showbutton: false
  206. })
  207. },
  208. });