index.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. Page({
  2. dever: getApp().dever,
  3. product: null,
  4. data: {
  5. content: "",
  6. product_id: ''
  7. },
  8. onLoad: function (options) {
  9. var that = this;
  10. that.setData({
  11. id: options.id
  12. });
  13. that.dever.request('product.api.view',{
  14. signature: '',
  15. id: options.id
  16. }, {
  17. success: function (data, res) {
  18. that.product = data.product;
  19. var temp = that.dever.html('content', data.product.content, that);
  20. that.setData({
  21. content: temp
  22. })
  23. }
  24. });
  25. },
  26. /**
  27. * 分享
  28. */
  29. onShareAppMessage: function (options){
  30. wx.showShareMenu({
  31. withShareTicket: true,
  32. success: function(res){
  33. //TODO
  34. },
  35. fail: function(res){
  36. //TODO
  37. }
  38. })
  39. //options.from可以用来判断是从自定义button打开的转发页面,还是从右上角的打开的转发页面。
  40. },
  41. /**
  42. * 立即购买
  43. */
  44. doBuy: function(event){
  45. var that = this;
  46. var id;
  47. if (typeof (event) == 'object') {
  48. id = event.currentTarget.dataset.id
  49. } else {
  50. id = event
  51. }
  52. this.dever.isLogin(function (res) {
  53. if (res) {
  54. that.dever.location('carts/index?id=' + id);
  55. } else {
  56. that.dever.location('login/index');
  57. }
  58. });
  59. }
  60. })