index.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. // pages/quality/detail/index.js
  2. let wxparse = require("../../../wxParse/wxParse.js");
  3. var util = require("../../../utils/util.js");
  4. const tool = require("../../../utils/tool");
  5. var app = getApp();
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. appAssetsUrl2: app.appAssetsUrl2,
  12. appAssetsUrl3: app.appAssetsUrl3,
  13. user: {},
  14. popup2: null,
  15. detail: {},
  16. },
  17. /**
  18. * 生命周期函数--监听页面加载
  19. */
  20. onLoad(options) {
  21. this.getDetail(options.id);
  22. },
  23. /**
  24. * 生命周期函数--监听页面初次渲染完成
  25. */
  26. onReady() {
  27. this.popup2 = this.selectComponent("#popup2");
  28. },
  29. /**
  30. * 生命周期函数--监听页面显示
  31. */
  32. onShow() {
  33. this.setData({
  34. user: wx.getStorageSync("USER") || {}
  35. })
  36. },
  37. getDetail(id) {
  38. app._get(`goods/info/${id}`, {}, (res) => {
  39. if (res.code == 0) {
  40. this.setData({
  41. detail: res.goods,
  42. });
  43. wxparse.wxParse("details", "html", res.goods.details, this, 0);
  44. }
  45. });
  46. },
  47. wantTo(e) {
  48. if (this.data.user && !this.data.user.id) {
  49. tool.alert("请先前往个人中心进行登录授权");
  50. return false;
  51. }
  52. if (this.data.user.memberState == 0 && this.data.detail.memberApply) {
  53. tool.alert("您还不是会员,请联系平台客服处理");
  54. return false;
  55. }
  56. this.popup2.showPopup();
  57. app._post_form(
  58. "goodsapply/save",
  59. "application/json",
  60. {
  61. userId: this.data.user.id,
  62. goodsId: this.data.detail.id,
  63. },
  64. function (res) {}
  65. );
  66. },
  67. seeBigCode(e) {
  68. let arr = [this.data.detail.qrCode];
  69. wx.previewImage({
  70. urls: arr, // 需要预览的图片http链接列表
  71. });
  72. },
  73. _success(e) {
  74. this.popup2.hidePopup();
  75. },
  76. //取消事件
  77. _error(e) {
  78. this.popup2.hidePopup();
  79. },
  80. /**
  81. * 生命周期函数--监听页面隐藏
  82. */
  83. onHide() {},
  84. /**
  85. * 生命周期函数--监听页面卸载
  86. */
  87. onUnload() {},
  88. /**
  89. * 页面相关事件处理函数--监听用户下拉动作
  90. */
  91. onPullDownRefresh() {},
  92. /**
  93. * 页面上拉触底事件的处理函数
  94. */
  95. onReachBottom() {},
  96. /**
  97. * 用户点击右上角分享
  98. */
  99. onShareAppMessage() {},
  100. });