shareDialog.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. // pages/components/shareDialog/shareDialog.js
  2. const getReq = require('../../../config').getReq;
  3. let app = getApp();
  4. Component({
  5. /**
  6. * 组件的属性列表
  7. */
  8. properties: {
  9. showDialog:{
  10. type:Boolean,
  11. value:false
  12. },
  13. goods_id: {
  14. type: Number,
  15. observer() {
  16. console.log('observer goods_id = ', this.properties.goods_id)
  17. let goods_id = this.properties.goods_id
  18. if(goods_id > 0) {
  19. this.requestData(goods_id);
  20. this.setData({shareModel: app.cardShareInfo()})
  21. }
  22. else {
  23. }
  24. }
  25. }
  26. },
  27. /**
  28. * 组件的初始数据
  29. */
  30. data: {
  31. current_goodsid:0,
  32. fGoodsRequesting: false,
  33. tip:'',
  34. invitess:[],
  35. policy:[],
  36. tip_title:'',
  37. tip_num:0,
  38. shareModel:{}
  39. },
  40. pageLifetimes: {
  41. // 组件所在页面的生命周期函数
  42. show: function () {
  43. console.log('pageLifetimes goods_id = ', this.properties.goods_id)
  44. },
  45. hide: function () {
  46. console.log('pageLifetimes goods_id = ', this.properties.goods_id)
  47. },
  48. resize: function () { },
  49. },
  50. lifetimes: {
  51. attached: function () {
  52. console.log('lifetimes attached')
  53. wx.getSetting({
  54. withSubscriptions: true,
  55. success(res) {
  56. var itemSettings = res.subscriptionsSetting.itemSettings
  57. console.log('setting:', itemSettings)
  58. if (itemSettings) {
  59. if (itemSettings['模版id'] === 'accept') {
  60. }
  61. }
  62. }
  63. })
  64. },
  65. detached: function () {
  66. },
  67. },
  68. /**
  69. * 组件的方法列表
  70. */
  71. methods: {
  72. onCloseDialog() {
  73. wx.requestSubscribeMessage({
  74. tmplIds: ['zBNktaey9EM2DcBzUNsjnAan2NvYpj_nKZDY__f9pGA'],
  75. success(res) {
  76. console.log(res)
  77. }
  78. })
  79. console.log('onCloseDialog');
  80. this.triggerEvent('closeDialog', {})
  81. },
  82. onShareInfo(){
  83. console.log('onShareInfo');
  84. this.triggerEvent('onShareInfo', {})
  85. },
  86. requestData(goods_id)
  87. {
  88. console.log('requestData goods_id=',goods_id)
  89. if (this.fGoodsRequesting) return;
  90. this.fGoodsRequesting = true
  91. getReq(app, {
  92. act: 'member_invitee',
  93. op: 'goods_share',
  94. goods_id: goods_id,
  95. }, (res) => {
  96. console.log('res:', res)
  97. if (res.code == 200) {
  98. if (res.datas) {
  99. let invitess = res.datas.invitess
  100. let policy = res.datas.policy
  101. let tip_title = res.datas.tip_title
  102. let tip_num = res.datas.tip_num
  103. this.setData({ tip_title,tip_num,invitess, policy })
  104. }
  105. }
  106. this.fGoodsRequesting = false
  107. })
  108. }
  109. }
  110. })