index.js 2.2 KB

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