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.

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