| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- // CRM/customer/modules/order/details.js
- const _Http = getApp().globalData.http,
- currency = require("../../../../utils/currency"),
- CNY = value => currency(value, {
- symbol: "¥",
- precision: 2
- }).format();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- list: [],
- loading: false,
- sa_custorderid: '',
- content: {
- nocache: true,
- pageNumber: 1,
- pageSize: 20,
- pageTotal: 1,
- total: null
- }
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- if (options.id) {
- this.setData({ sa_custorderid: options.id });
- this.getList(options.id, true);
- }
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- this.getList(this.data.sa_custorderid, true);
- wx.stopPullDownRefresh();
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- if (this.data.content.pageNumber <= this.data.content.pageTotal) {
- this.getList(this.data.sa_custorderid, false);
- }
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- },
- /**
- * 获取订单明细列表
- */
- getList(id, init) {
- let content = this.data.content;
- content.sa_custorderid = id || this.data.sa_custorderid;
- if (init) {
- content.pageNumber = 1;
- this.setData({ loading: true });
- }
- _Http.basic({
- "id": "2026031414243401",
- content
- }).then(res => {
- this.setData({ loading: false });
- console.log("订单明细列表", res)
- if (res.code != 1) return wx.showToast({
- title: res.msg,
- icon: "none"
- })
- // 格式化金额数据
- const formattedData = res.data.map(item => {
- const amount = (item.price || 0) * (item.qty || 0);
- return {
- ...item,
- showPrice: CNY(item.price || 0),
- showAmount: CNY(amount)
- };
- })
- this.setData({
- list: res.pageNumber == 1 ? formattedData : this.data.list.concat(formattedData),
- "content.pageNumber": res.pageNumber + 1,
- "content.pageSize": res.pageSize,
- "content.pageTotal": res.pageTotal,
- "content.total": res.total
- })
- })
- }
- })
|