index.js 944 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. const app = getApp();
  2. Page({
  3. pid: '',
  4. onLoad: function (options) {
  5. this.pid = options.id;
  6. var that = this;
  7. app.showLoading();
  8. app.request('product.api.view', {id: this.pid}, {
  9. success: function (data, res) {
  10. app.html('content', data.product.content, that);
  11. },
  12. complete: function(res){
  13. app.hideLoading();
  14. }
  15. })
  16. },
  17. /**
  18. * 跳转海报分享页面,分享海报
  19. */
  20. toShare: function(){
  21. if(app.isLogin()){
  22. app.location('poster/index?id=' + this.pid);
  23. }else{
  24. app.location('login/index');
  25. }
  26. },
  27. /**
  28. * 立即购买
  29. */
  30. doBuy: function(e){
  31. var that = this;
  32. if(app.isLogin()){
  33. app.request('product.api.addCarts', {product_id: this.pid, num: 1}, {
  34. success: function (data, res) {
  35. app.location('carts/index?id=' + that.pid);
  36. }
  37. })
  38. } else {
  39. app.location('login/index');
  40. }
  41. }
  42. })