免费国产欧美国日产_少妇AV一区二区三区无码_蜜桃精品av无码喷奶水小说_jk18禁网站视频_精产国品一二三级产品区别_被夫の上司に犯波多野结衣_78m成人手机免费看_最爽最刺激18禁视频_偷偷色噜狠狠狠狠的777米奇

小程序商品下單展示

用于獲取小程序的商品下單展示數(shù)據(jù)


使用步驟

第一步:配置接口地址

config.js 文件中找到 config 設(shè)置

第二步:檢查接口定義

搜索 shop_product_buy 接口是否已經(jīng)存在定義(有的小程序模板已經(jīng)定義)

如果沒有定義,在 config 底部新增以下代碼:

shopProductBuyUrl: getApiUrl('shop_product_buy'),

并復(fù)制紅色部分待用。如果已經(jīng)存在,則直接復(fù)制使用即可。

第三步:接口調(diào)用請求

如果定義名稱不同,使用第二步復(fù)制的內(nèi)容替換紅框部分

/**
* 獲取當(dāng)前訂單信息
* 接收參數(shù)
* 無需接收參數(shù),從頁面數(shù)據(jù)中取值
* 接口傳參
* querystr:訂單數(shù)據(jù)密鑰字符串
*/
getOrderData() {
    let _this = this;
    if (_this.data.is_buy_pay && _this.data.options.querystr) {
        return false;
    } else if (_this.data.is_cart_pay && !_this.data.options.querystr) {
        return false;
    } else {
        App._requestPost(_this, App.globalData.config.shopProductBuyUrl, {querystr: _this.data.options.querystr},
            function (res) {
                // 優(yōu)惠券價(jià)格變?yōu)檎麛?shù)
                let coupon_list = res.data.coupon_data;
                if (coupon_list) {
                    coupon_list.forEach((value, index) => {
                        value["coupon_price"] = parseInt(value["coupon_price"])
                    });
                }
                let unuse_coupon_list = res.data.unuse_coupon_data;
                if (unuse_coupon_list) {
                    unuse_coupon_list.forEach((value, index) => {
                        value["coupon_price"] = parseInt(value["coupon_price"])
                    });
                }
                // 商品規(guī)格處理
                let prom_type = _this.data.prom_type;
                let product_data = res.data.product_data;
                if (product_data) {
                    product_data.forEach(item => {
                        let product_spec = item.product_spec.split(';')
                        _this.setData({product_spec: product_spec});
                        if (1 == prom_type && 0 == item.prom_type) prom_type = 0;
                    });
                }
                // 加載數(shù)據(jù)到頁面
                let userInfo = res.data.users;
                let address = res.data.address;
                let global_info = res.data.global_info;
                let exist_address = address.addr_id ? true : false;
                _this.setData({product_data, global_info, address, exist_address, coupon_list, unuse_coupon_list, prom_type, userInfo});
            },
            function (res) {
                App.showError(res.msg);
            }
        );
    }
},

接口傳值

querystr:訂單數(shù)據(jù)密鑰字符串,必傳


文檔最后更新時間:2026-01-13 14:51:48

文檔
目錄

深色
模式

切換
寬度