wheel/pages/menu/menu.js
2019-11-29 13:52:16 +08:00

45 lines
1.1 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var page = {
data: {
textList: [],
},
onShow: function(e) {
this.getData()
},
getData() {
wx.request({
// url: 'https://mp-test.kingsome.cn/api/open/zp/text', //开发者服务器接口地址",
url: 'http://localhost:2333/api/open/zp/text', //开发者服务器接口地址",
data: 'data', //请求的参数",
method: 'GET',
dataType: 'json', //如果设为json会尝试对返回的数据做一次 JSON.parse
success: res => {
const data = res.data
if (data.errcode === 0) {
const textList = data.result
this.setData({
textList: textList,
})
} else {
wx.showToast({
title: data.errmsg, //提示的内容,
icon: 'fail', //图标,
})
}
},
fail: () => {
wx.showToast({
title: '获取数据时出错!', //提示的内容,
icon: 'fail', //图标,
})
},
})
},
goDetails(e) {
const _id = e.target.dataset.id
wx.navigateTo({
url: `/pages/index/index?_id=${_id}`,
})
},
}
Page(page)