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.

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