C端小程序
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

244 строки
6.6 KiB

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