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

219 行
5.7 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. showIndexReuturn:false
  59. },
  60. phone: function(e) {
  61. let that = this;
  62. wx.makePhoneCall({
  63. phoneNumber: e.target.dataset.merchantlinkphone
  64. });
  65. },
  66. gotoIndex(){
  67. wx.navigateTo({
  68. url: '/pages/index/index',
  69. })
  70. },
  71. goToTranser(){
  72. this.onShareAppMessage();
  73. // wx.navigateTo({
  74. // url: '/pages/index/index?couponChannelId=' + this.data.cardDetail.couponChannelId + '&cuserId=' + this.data.cardDetail.cuserId + '&couponId=' + this.data.cardDetail.couponId,
  75. // })
  76. },
  77. onShareAppMessage: function (res) {
  78. let _this = this;
  79. return {
  80. title: '领取卡',
  81. path: '/pages/index/index?couponChannelId=' + this.data.cardDetail.couponChannelId + '&cuserId=' + this.data.cardDetail.ownerId + '&couponId=' + this.data.cardDetail.couponId + '&coverImg=' + this.data.cardDetail.coverImg + '&userName=' + this.data.userName + '&avatarUrl=' + this.data.avatarUrl + '&couponOrderId=' + this.data.cardDetail.id + '&updateDate=' + this.data.cardDetail.updateDate,
  82. imageUrl: this.data.cardDetail.coverImg,
  83. success: function (res) {
  84. // 转发成功
  85. },
  86. fail: function (res) {
  87. // 转发失败
  88. }
  89. }
  90. },
  91. // 点击查看更多
  92. more: function() {
  93. let that = this;
  94. if (that.data.more == '点击查看更多') {
  95. this.setData({
  96. hidden: "",
  97. height: that.data.cardDetail.merchantVoList.length * 140 + 'rpx',
  98. more: "点击收起",
  99. showMore: true
  100. })
  101. }
  102. else {
  103. this.setData({
  104. hidden: "hidden",
  105. height: 4* 140 + 'rpx',
  106. more: "点击查看更多",
  107. showMore: true
  108. })
  109. }
  110. },
  111. onLoad(options) {
  112. let that = this;
  113. console.log(options.cardId)
  114. that.cardpayList(options.cardId);
  115. that.cardDetail(options.cardId);
  116. if (options.from){
  117. this.setData({
  118. showIndexReuturn:true
  119. })
  120. }
  121. },
  122. cardpayList: function(cardId) {
  123. let that = this;
  124. wx.showLoading({
  125. title: "加载中..."
  126. });
  127. var parmer = {
  128. url: config.api.cardpayList,
  129. data: {
  130. cardId: cardId,
  131. pageNum: 1,
  132. pageSize: 100
  133. }
  134. };
  135. Http.get(parmer)
  136. .then(res => {
  137. console.log(res);
  138. if (res.code == 200 && res.data.list.length > 0) {
  139. that.setData({
  140. showPage: true
  141. })
  142. } else {}
  143. wx.hideLoading();
  144. res.data.list.map(file => {
  145. file.updateDate = util.formatTime(file.updateDate, "yyyy-MM-dd hh:mm:ss")
  146. })
  147. that.setData({
  148. data: res.data.list
  149. });
  150. }).catch(err => {
  151. wx.showToast({
  152. title: err.message,
  153. icon: 'none',
  154. duration: 2000,
  155. mask: false
  156. });
  157. })
  158. },
  159. getUserInfo: function () {
  160. let that = this;
  161. // 获取用户信息
  162. Http.get({
  163. url: config.api.getScore,
  164. data: {}
  165. })
  166. .then(res => {
  167. console.log(res)
  168. that.setData({
  169. userName: res.data.nickName,
  170. avatarUrl: res.data.avatarUrl
  171. })
  172. })
  173. },
  174. cardDetail: function(couponOrderId) {
  175. let that = this;
  176. Http.get({
  177. url: config.api.cardDetail,
  178. data: {
  179. couponOrderId: couponOrderId
  180. }
  181. })
  182. .then(res => {
  183. console.log(res)
  184. if (res.code == 200) {
  185. res.data.expiredTime = util.formatTime(res.data.expiredTime, "yyyy-MM-dd hh:mm:ss")
  186. that.setData({
  187. showPage: true,
  188. cardDetail: res.data,
  189. supportTransfer: res.data.supportTransfer
  190. })
  191. /**
  192. * 若可转赠获取用户头像信息
  193. */
  194. if (res.data.supportTransfer){
  195. that.getUserInfo()
  196. }
  197. if (that.data.cardDetail.merchantVoList && that.data.cardDetail.merchantVoList.length<=4){
  198. that.setData({
  199. height: that.data.cardDetail.merchantVoList.length * 140 + 'rpx',
  200. showMore:false
  201. })
  202. } else if (that.data.cardDetail.merchantVoList && that.data.cardDetail.merchantVoList.length > 4){
  203. that.setData({
  204. height: 4 * 140 + 'rpx'
  205. })
  206. }
  207. }
  208. })
  209. .catch(err => {
  210. console.log(err)
  211. })
  212. },
  213. onShow() {
  214. let that = this;
  215. that.setData({
  216. showbutton: false
  217. })
  218. },
  219. });