article.js 1.31 KB
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
// packageA/pages/article/article.js
import api from "../../../utils/apiFile.js";
var networkUtil = require('../../../utils/network_util.js')
Page({
data: {
id: "",
article: {},
typeList: [
{id: 1, name: "中医饮食调养指导"},
{id: 2, name: "中医起居调摄指导"},
{id: 3, name: "传授摩腹、捏脊方法"},
{id: 4, name: "传授按揉迎香穴、足三里穴方法"},
{id: 5, name: "传授按揉四神聪穴方法"},
{id: 6, name: "其他"}
]
},
onLoad: function (options) {
this.data.id = options.id;
// console.log(this.data.id)
this.getArticle()
},
getArticle() {
let _this = this
networkUtil._get(api.getArticle, {}, function(res) {
if(0 == res.data.errorcode){
for (let i in res.data.data) {
let typeStr = _this.getTypeStr(res.data.data[i].type)
res.data.data[i].typeStr = typeStr
if (_this.data.id === res.data.data[i].id) {
_this.setData({
article: res.data.data[i]
})
}
}
}
}, function(res) {
networkUtil.showErrorToast(res.errormsg)
})
},
getTypeStr(type) {
for (let i in this.data.typeList) {
if (type === this.data.typeList[i].id) {
return this.data.typeList[i].name
}
}
}
})