|
@@ -1,4 +1,5 @@
|
|
|
// pages/welfareMall/couponFitFood/index.js
|
|
|
+import activity from '../../../api/activity'
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
@@ -12,7 +13,17 @@ Page({
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
-
|
|
|
+ console.log(options)
|
|
|
+ if (!options.couponId) {
|
|
|
+ wx.reLaunch({
|
|
|
+ url: '/pages/welfareMall/index/index',
|
|
|
+ })
|
|
|
+ }
|
|
|
+ this.data.couponId = options.couponId
|
|
|
+ this.setData({
|
|
|
+ couponName: decodeURIComponent(options.couponName)
|
|
|
+ })
|
|
|
+ this.loadData()
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -62,5 +73,27 @@ Page({
|
|
|
*/
|
|
|
onShareAppMessage: function () {
|
|
|
|
|
|
+ },
|
|
|
+ loadData() {
|
|
|
+ activity.getFoodListByCoupon({
|
|
|
+ couponId: this.data.couponId,
|
|
|
+ page: 1,
|
|
|
+ pageSize: 10000,
|
|
|
+ }).then(data => {
|
|
|
+ if (data.code == 200) {
|
|
|
+ this.dataMapToView(data.data)
|
|
|
+ }
|
|
|
+ }).catch(_ => {
|
|
|
+ console.log(_)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ dataMapToView(data) {
|
|
|
+ const foodList = []
|
|
|
+ data.forEach(v => {
|
|
|
+ foodList.push(v.foodName)
|
|
|
+ })
|
|
|
+ this.setData({
|
|
|
+ foodListStr: foodList.join("、")
|
|
|
+ })
|
|
|
}
|
|
|
})
|