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.

245 lines
6.7 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. let cardId = options.cardId
  135. console.log(cardId)
  136. if (cardId == undefined) {
  137. cardId = 0;
  138. }
  139. that.cardpayList(cardId);
  140. that.cardDetail(cardId);
  141. if (options.from){
  142. this.setData({
  143. showIndexReuturn:true
  144. })
  145. }
  146. wx.hideShareMenu()
  147. },
  148. cardpayList: function(cardId) {
  149. let that = this;
  150. wx.showLoading({
  151. title: "加载中..."
  152. });
  153. var parmer = {
  154. url: config.api.cardpayList,
  155. data: {
  156. cardId: cardId,
  157. pageNum: 1,
  158. pageSize: 100
  159. }
  160. };
  161. Http.get(parmer)
  162. .then(res => {
  163. console.log(res);
  164. if (res.code == 200 && res.data.list.length > 0) {
  165. that.setData({
  166. showPage: true
  167. })
  168. } else {}
  169. wx.hideLoading();
  170. res.data.list.map(file => {
  171. file.updateDate = util.formatTime(file.updateDate, "yyyy-MM-dd hh:mm:ss")
  172. })
  173. that.setData({
  174. data: res.data.list
  175. });
  176. }).catch(err => {
  177. wx.showToast({
  178. title: err.message,
  179. icon: 'none',
  180. duration: 2000,
  181. mask: false
  182. });
  183. })
  184. },
  185. getUserInfo: function () {
  186. let that = this;
  187. // 获取用户信息
  188. Http.get({
  189. url: config.api.getScore,
  190. data: {}
  191. })
  192. .then(res => {
  193. console.log(res)
  194. that.setData({
  195. userName: res.data.nickName,
  196. avatarUrl: res.data.avatarUrl
  197. })
  198. })
  199. },
  200. cardDetail: function(couponOrderId) {
  201. let that = this;
  202. Http.get({
  203. url: config.api.cardDetail,
  204. data: {
  205. couponOrderId: couponOrderId
  206. }
  207. })
  208. .then(res => {
  209. console.log(res)
  210. if (res.code == 200) {
  211. res.data.expiredTime = util.formatTime(res.data.expiredTime, "yyyy-MM-dd hh:mm:ss")
  212. that.setData({
  213. showPage: true,
  214. cardDetail: res.data,
  215. supportTransfer: res.data.supportTransfer
  216. })
  217. /**
  218. * 若可转赠获取用户头像信息
  219. */
  220. if (res.data.supportTransfer){
  221. that.getUserInfo()
  222. }
  223. if (that.data.cardDetail.merchantVoList && that.data.cardDetail.merchantVoList.length<=4){
  224. that.setData({
  225. height: that.data.cardDetail.merchantVoList.length * 140 + 'rpx',
  226. showMore:false
  227. })
  228. } else if (that.data.cardDetail.merchantVoList && that.data.cardDetail.merchantVoList.length > 4){
  229. that.setData({
  230. height: 4 * 140 + 'rpx'
  231. })
  232. }
  233. }
  234. })
  235. .catch(err => {
  236. console.log(err)
  237. })
  238. },
  239. onShow() {
  240. let that = this;
  241. that.setData({
  242. showbutton: false
  243. })
  244. },
  245. });