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.

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