C端小程序
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

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