buy.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // pages/buy/buy.js
  2. import { goodsList } from '../../api/index'
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. activeIndex: -1,
  9. goodsList: []
  10. },
  11. /**
  12. * 生命周期函数--监听页面显示
  13. */
  14. onShow() {
  15. this.getGoodsList()
  16. },
  17. //获取套餐列表
  18. getGoodsList () {
  19. wx.showLoading({
  20. title: '加载中...',
  21. mask: true
  22. })
  23. goodsList({}).then(res => {
  24. wx.hideLoading()
  25. var response = res.data
  26. response.map((item, index) => {
  27. if (item.isRecommend) {
  28. this.setData({
  29. activeIndex: index
  30. })
  31. }
  32. })
  33. this.setData({
  34. goodsList: response
  35. })
  36. }).catch(e => {
  37. wx.hideLoading()
  38. wx.showModal({
  39. content: e,
  40. confirmColor: '#333',
  41. showCancel: false
  42. })
  43. })
  44. },
  45. handlePayType (e) {
  46. var index = Number(e.currentTarget.dataset.index)
  47. this.setData({
  48. activeIndex: index
  49. })
  50. },
  51. // 调用微信支付
  52. handleWXPay () {
  53. },
  54. handleAppointment () {
  55. wx.navigateTo({
  56. url: '/pages/appointment/appointment',
  57. })
  58. }
  59. })