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.

316 lines
8.9 KiB

  1. let config = require("../../../config/config.js");
  2. let util = require("../../../utils/util");
  3. let Http = require("../../../utils/HttpBasics");
  4. let app = getApp();
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. showModalStatus: false,
  11. flag: 0
  12. },
  13. /**
  14. * 点击弹出二维码
  15. * 然后再关闭
  16. */
  17. powerDrawer: function(e) {
  18. var currentStatu = e.currentTarget.dataset.statu;
  19. console.log(e.currentTarget.dataset.statu);
  20. console.log(e.currentTarget.dataset.quancode);
  21. this.utils(currentStatu, e.currentTarget.dataset.quancode);
  22. },
  23. utils: function(currentStatu, quancode) {
  24. /* 动画部分 */
  25. // 第1步:创建动画实例
  26. var animation = wx.createAnimation({
  27. duration: 200, //动画时长
  28. timingFunction: "linear", //线性
  29. delay: 0 //0则不延迟
  30. }); // 第2步:这个动画实例赋给当前的动画实例
  31. this.animation = animation; // 第3步:执行第一组动画
  32. animation.opacity(0).step(); // 第4步:导出动画对象赋给数据对象储存
  33. this.setData({
  34. animationData: animation.export()
  35. }); // 第5步:设置定时器到指定时候后,执行第二组动画
  36. setTimeout(
  37. function() {
  38. // 执行第二组动画
  39. animation.opacity(1).step(); // 给数据对象储存的第一组动画,更替为执行完第二组动画的动画对象
  40. this.setData({
  41. animationData: animation
  42. }); //关闭
  43. if (currentStatu == "close") {
  44. this.setData({
  45. showModalStatus: false
  46. });
  47. }
  48. }.bind(this),
  49. 20
  50. );
  51. // 显示
  52. if (currentStatu == "open") {
  53. this.setData({
  54. showModalStatus: true
  55. });
  56. this.data.flag++;
  57. console.log(this.data.flag);
  58. util.barcode("barcode" + this.data.flag, quancode, 500, 100);
  59. util.qrcode("qrcode" + this.data.flag, quancode, 350, 350);
  60. this.setData({
  61. flag: this.data.flag
  62. });
  63. }
  64. },
  65. /**
  66. * 生命周期函数--监听页面加载
  67. */
  68. onLoad: function(options) {
  69. let that = this;
  70. console.log(options.orderId);
  71. console.log(options.flag + "我是付款的标识");
  72. Http.get({
  73. url: config.api.orderDetail,
  74. data: {
  75. orderId: options.orderId
  76. }
  77. }).then(res => {
  78. console.log(res);
  79. console.log("我是订单详情");
  80. that.setData({
  81. data: res.data
  82. });
  83. //createDate 创建时间
  84. var createDate = util.fmtDate(res.data.createDate);
  85. console.log(createDate);
  86. that.setData({
  87. createDate: createDate
  88. });
  89. });
  90. },
  91. /**
  92. * 发起支付
  93. */
  94. // orderFunc(e) {
  95. // var that = this;
  96. // console.log(e.currentTarget.dataset.couponchannelid);
  97. // wx.showLoading({
  98. // title: "加载中..."
  99. // });
  100. // Http.post({
  101. // url: config.api.checkPhoneStatus,
  102. // data: {}
  103. // })
  104. // .then(res => {
  105. // console.log(res);
  106. // /**
  107. // * orderSave 下单
  108. // */
  109. // return Http.post({
  110. // url: config.api.orderSave,
  111. // data: {
  112. // couponChannelId: "" + e.currentTarget.dataset.couponchannelid,
  113. // couponId: "" + that.data.couponId
  114. // }
  115. // });
  116. // })
  117. // .catch(err => {
  118. // console.log(err);
  119. // if (err.code == 11005) {
  120. // // 用户手机未授权
  121. // wx.redirectTo({
  122. // url:
  123. // "../../getphoneInfo/index?couponChannelId=" +
  124. // that.data.couponChannelId +
  125. // "&couponId=" +
  126. // that.data.couponId
  127. // });
  128. // }
  129. // if (err.code == 11006) {
  130. // // 用户手机已加密
  131. // wx.redirectTo({
  132. // url:
  133. // "../../phoneinput/phoneinput?couponChannelId=" +
  134. // that.data.couponChannelId +
  135. // "& couponId=" +
  136. // that.data.couponId
  137. // });
  138. // }
  139. // })
  140. // .then(res => {
  141. // if (res != "undefined") {
  142. // const orderId = "" + res.data.id;
  143. // that.setData({
  144. // orderId: orderId
  145. // });
  146. // if (res.data.payment > 0) {
  147. // // 支付金额不为0
  148. // /**
  149. // * 支付订单创建
  150. // */
  151. // Http.post({
  152. // url: config.api.payOrderCreate,
  153. // data: {
  154. // orderId: orderId
  155. // }
  156. // }).then(res => {
  157. // console.log(res);
  158. // /// Begin payment ----
  159. // var payOrderId = "" + res.data.payOrderId;
  160. // wx.hideLoading();
  161. // wx.requestPayment({
  162. // timeStamp: res.data.timeStamp,
  163. // nonceStr: res.data.nonceStr,
  164. // package: res.data.package,
  165. // signType: "MD5",
  166. // paySign: res.data.paySign,
  167. // success: res => {
  168. // console.log(res);
  169. // console.log("姐在检查付款异常");
  170. // that.payOrderUpdate(that.data.orderId, payOrderId, 1); // 支付成功
  171. // console.log(res);
  172. // if (res.errMsg == "requestPayment:ok") {
  173. // wx.showToast({
  174. // title: "购买成功",
  175. // duration: 2500
  176. // });
  177. // }
  178. // wx.navigateBack({
  179. // delta: 2
  180. // });
  181. // },
  182. // fail: res => {
  183. // that.payOrderUpdate(that.data.orderId, payOrderId, 2); // 支付失败
  184. // console.log(res);
  185. // return;
  186. // },
  187. // complete: res => {
  188. // console.log(res);
  189. // console.log("支付完成");
  190. // // var url = res.data.url;
  191. // // console.log("get url", url);
  192. // if (res.errMsg == "requestPayment:ok") {
  193. // wx.showModal({
  194. // title: "提示",
  195. // content: "支付成功"
  196. // });
  197. // // if (url) {
  198. // // setTimeout(function () {
  199. // // wx.redirectTo({
  200. // // url: "/pages" + url
  201. // // });
  202. // // }, 2000);
  203. // // } else {
  204. // // setTimeout(() => {
  205. // // wx.navigateBack();
  206. // // }, 2000);
  207. // // }
  208. // } else {
  209. // wx.showToast({
  210. // title: "支付失败",
  211. // image: "./../../../assets/img/fail.png",
  212. // duration: 1500,
  213. // mask: false
  214. // });
  215. // }
  216. // return;
  217. // }
  218. // });
  219. // /// End payment --------
  220. // ///// virtual pay
  221. // //var payOrderId = "" + res.data.out_trade_no;
  222. // //that.payOrderUpdate(that.data.orderId, payOrderId, 1); // 支付成功
  223. // ///// end virtual pay
  224. // });
  225. // } else {
  226. // // 免费券
  227. // that
  228. // .payOrderUpdate(orderId, "0", 1) // 支付成功
  229. // .then(res => {
  230. // wx.showToast({
  231. // title: "支付成功",
  232. // duration: 3000
  233. // });
  234. // });
  235. // }
  236. // }
  237. // })
  238. // .catch(err => {
  239. // console.log(err);
  240. // });
  241. // },
  242. /**
  243. * 支付订单更新
  244. */
  245. // payOrderUpdate: (orderId, payOrderId, status, reason) => {
  246. // // 支付成功
  247. // Http.post({
  248. // url: config.api.payOrderUpdate,
  249. // data: {
  250. // payOrderId: payOrderId,
  251. // orderId: orderId,
  252. // status: status,
  253. // reason: reason
  254. // }
  255. // })
  256. // .then(res => {
  257. // console.log("payOrderUpdate then", res);
  258. // // wx.showToast({
  259. // // title: "购买成功",
  260. // // duration: 2500
  261. // // });
  262. // })
  263. // .catch(err => {
  264. // console.log("payOrderUpdate catch", err);
  265. // });
  266. // },
  267. /**
  268. * 生命周期函数--监听页面初次渲染完成
  269. */
  270. onReady: function() {},
  271. /**
  272. * 生命周期函数--监听页面显示
  273. */
  274. onShow: function(options) {},
  275. /**
  276. * 生命周期函数--监听页面隐藏
  277. */
  278. onHide: function() {},
  279. /**
  280. * 生命周期函数--监听页面卸载
  281. */
  282. onUnload: function() {},
  283. /**
  284. * 页面相关事件处理函数--监听用户下拉动作
  285. */
  286. onPullDownRefresh: function() {},
  287. /**
  288. * 页面上拉触底事件的处理函数
  289. */
  290. onReachBottom: function() {},
  291. /**
  292. * 用户点击右上角分享
  293. */
  294. onShareAppMessage: function() {}
  295. });