同上一篇js部分紧接
wx.request({ //从后端获取数据
url: 'http://127.0.0.1:8000/api/wx-qiye/', //后端传数据的路径
data: {},
header: {
'content-type': 'application/json' // 默认值
},
success(res) {
console.log(res)
self.setData({
qiyeList: res.data.qiyeList,
})
}
})
wxml
<van-card tag='XXX' title="{{item.asd}}" desc="{{item.qwe}}" price="2000.00" origin-price="3000.00" thumb="{{item.zxc}}">
<view slot="footer">
<van-button plain type="info" size="small">参加</van-button>
</view>
</van-card>
接着获取openid的api.py
在这里插入代码片@api_view(['GET','POST'])
def QiyeView(request):
querysets = Qiye.objects.all()
# print(querysets)
querysetsList = querysets.values()
qiyeList = []
for item in querysetsList:
qiye = {'asd':item['asd'],'qwe':item['qwe'],'zxc':'http://127.0.0.1:8000/upload/'+item["zxc"],}
qiyeList.append(qiye)
qiyeList = qiyeList[::-1]
return Response({'qiyeList':qiyeList})