添加组件及页面
This commit is contained in:
15
miniprogram/pages/other/goodsDetail/goodsDetail.json
Normal file
15
miniprogram/pages/other/goodsDetail/goodsDetail.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"search-popup": "/pages/components/search-popup/search-popup",
|
||||
"card-plugin": "/pages/components/card-plugin/card-plugin",
|
||||
"card-item-plugin": "/pages/components/card-item-plugin/card-item-plugin",
|
||||
"option-cell-plugin": "/pages/components/option-cell-plugin/option-cell-plugin",
|
||||
"date-picker-plugin": "/pages/components/date-picker-plugin/date-picker-plugin",
|
||||
"sort-plugin": "/pages/components/sort-plugin/sort-plugin",
|
||||
"count-plugin": "/pages/components/count-plugin/count-plugin",
|
||||
"total-bar-plugin": "/pages/components/total-bar-plugin/total-bar-plugin",
|
||||
"pagination-plugin": "/pages/components/pagination-plugin/pagination-plugin",
|
||||
"search-input": "/pages/components/search-input/search-input"
|
||||
},
|
||||
"navigationBarTitleText": "商品详情"
|
||||
}
|
||||
173
miniprogram/pages/other/goodsDetail/goodsDetail.ts
Normal file
173
miniprogram/pages/other/goodsDetail/goodsDetail.ts
Normal file
@@ -0,0 +1,173 @@
|
||||
import { loginStatus, post } from '@/utils/https';
|
||||
import {
|
||||
cloneLite,
|
||||
getAuthInfo,
|
||||
getDataSet,
|
||||
showModal,
|
||||
sleep,
|
||||
toArray,
|
||||
toastSuccess,
|
||||
} from '@/utils/util';
|
||||
|
||||
const defaultParams = { curr_page: 1, page_count: 20 };
|
||||
|
||||
Page({
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
params: cloneLite(defaultParams) as any,
|
||||
list: [] as any[],
|
||||
count: 0,
|
||||
goods_id: '',
|
||||
sort: [],
|
||||
goodsSubAttr: {} as any,
|
||||
},
|
||||
handleLogin(e: any) {
|
||||
this.setData({ isLogin: e.detail });
|
||||
if (e.detail) {
|
||||
this.init();
|
||||
}
|
||||
},
|
||||
init() {
|
||||
this.setData({ authInfo: getAuthInfo() });
|
||||
|
||||
this.getGoodsAttr();
|
||||
},
|
||||
searchChange(e: any) {
|
||||
const key = getDataSet(e).key;
|
||||
this.data.params[key] = e.detail.value;
|
||||
this.setData({ params: this.data.params });
|
||||
},
|
||||
searchChange2(e: any) {
|
||||
const key = getDataSet(e).key;
|
||||
const val = `${e.detail.value || ''}`.trim();
|
||||
if (val) {
|
||||
this.data.params[key] = val;
|
||||
} else {
|
||||
delete this.data.params[key];
|
||||
}
|
||||
this.setData({ params: this.data.params });
|
||||
},
|
||||
onOptionChange(e: any) {
|
||||
const key = getDataSet(e).key;
|
||||
this.data.params[key] = e.detail.value;
|
||||
this.setData({ params: this.data.params });
|
||||
},
|
||||
datePickerConfirm(e: any) {
|
||||
const data = getDataSet(e);
|
||||
this.data.params[data.key] = e.detail.value;
|
||||
this.setData({ params: this.data.params });
|
||||
},
|
||||
searchOk() {
|
||||
this.getList();
|
||||
},
|
||||
searchReset() {
|
||||
this.data.params = cloneLite(defaultParams);
|
||||
this.getList();
|
||||
},
|
||||
onSort(e: any) {
|
||||
this.data.params.order = e.detail.value;
|
||||
this.setData({ params: this.data.params });
|
||||
this.getList();
|
||||
},
|
||||
getGoodsAttr() {
|
||||
post('GoodsAttr/list').then((res: any) => {
|
||||
this.data.goodsSubAttr = {};
|
||||
toArray(res?.data?.list).forEach((el) => {
|
||||
toArray(el.sub_attr).forEach((ell) => {
|
||||
this.data.goodsSubAttr[ell.attr_id] = {
|
||||
...ell,
|
||||
p_attr_name: el.attr_name,
|
||||
};
|
||||
});
|
||||
});
|
||||
// console.log(this.data.goodsSubAttr);
|
||||
this.setData({ goodsSubAttr: this.data.goodsSubAttr });
|
||||
this.getList();
|
||||
});
|
||||
},
|
||||
getList() {
|
||||
post('ErpGoods/getSkuPrice', { goods_id: this.data.goods_id }).then((res: any) => {
|
||||
const list = toArray(res.data).map((el) => {
|
||||
el.attr_id_arr = `${el.attr_id || ''}`.split(',');
|
||||
el.attr_name_arr = `${el.attr_name || ''}`.split(',');
|
||||
return el;
|
||||
});
|
||||
|
||||
// console.log(list);
|
||||
this.setData({ list });
|
||||
});
|
||||
},
|
||||
|
||||
onOrderDel(e: any) {
|
||||
const data = getDataSet(e);
|
||||
const index = data.index;
|
||||
const item = this.data.list[index];
|
||||
showModal({ content: `确认删除 ${item.order_no} 订单?` }).then(() => {
|
||||
post('Orders/delSaleOrders', { order_no: JSON.stringify([item.order_no]) }).then(() => {
|
||||
toastSuccess('删除成功');
|
||||
sleep(() => {
|
||||
this.getList();
|
||||
}, 1000);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
const { goods_id = '', title } = options;
|
||||
|
||||
this.data.goods_id = goods_id;
|
||||
if (title) {
|
||||
wx.setNavigationBarTitle({ title: decodeURIComponent(title) });
|
||||
}
|
||||
this.setData({ loading: true });
|
||||
loginStatus()
|
||||
.then(() => {
|
||||
this.setData({ isLogin: true, loading: false });
|
||||
this.init();
|
||||
})
|
||||
.catch((err) => {
|
||||
this.setData({ isLogin: false, loading: false });
|
||||
console.log('调用登录状态请求失败', err);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {},
|
||||
});
|
||||
40
miniprogram/pages/other/goodsDetail/goodsDetail.wxml
Normal file
40
miniprogram/pages/other/goodsDetail/goodsDetail.wxml
Normal file
@@ -0,0 +1,40 @@
|
||||
<page-plugin isAuth="{{authInfo['SF_ERP_GOODS_VIEW']}}" loading="{{loading}}" is-login="{{isLogin}}"
|
||||
bind:handleLogin="handleLogin">
|
||||
<!-- <search-popup placeholder="输入销售单号" bind:change="searchChange" bind:ok="searchOk"
|
||||
bind:reset="searchReset" value="{{params.order_no}}" data-key="order_no">
|
||||
<view slot="content">
|
||||
<search-input label="自定义单号" value="{{params.custom_order_no}}" data-key="custom_order_no"
|
||||
bind:change="searchChange2" />
|
||||
|
||||
<option-cell-plugin title="订单阶段" value="{{params.order_step}}" bind:change="onOptionChange"
|
||||
mode="checkbox" options="{{orderStep}}" data-key="order_step" />
|
||||
|
||||
<date-picker-plugin title="单据开始日期" value="{{params.document_dateL}}" data-key="document_dateL"
|
||||
bind:confirm="datePickerConfirm" />
|
||||
<date-picker-plugin title="单据结束日期" value="{{params.document_dateU}}" data-key="document_dateU"
|
||||
bind:confirm="datePickerConfirm" />
|
||||
|
||||
</view>
|
||||
</search-popup> -->
|
||||
|
||||
<empty-plugin wx:if="{{list.length == 0}}" />
|
||||
<card-plugin wx:for="{{ list }}" wx:key="goods_child_id" showAll>
|
||||
<view slot="header">{{ item.sku_code }}</view>
|
||||
<view slot="content">
|
||||
<card-item-plugin label="助记码" value="{{item.sku_alias}}" />
|
||||
<block wx:for="{{item.attr_id_arr}}" wx:key="index" wx:for-item="attr">
|
||||
<!-- 取配置的值 -->
|
||||
<!-- <card-item-plugin label="{{goodsSubAttr[item].p_attr_name}}"
|
||||
value="{{goodsSubAttr[item].attr_name}}" /> -->
|
||||
<card-item-plugin label="{{goodsSubAttr[attr].p_attr_name}}"
|
||||
value="{{item.attr_name_arr[index]}}" />
|
||||
</block>
|
||||
<card-item-plugin label="采购价格" value="{{item.purchase_price}}" />
|
||||
<card-item-plugin label="零售价格" value="{{item.commodity_price}}" />
|
||||
<card-item-plugin label="销售价格" value="{{item.wholesale_price}}" />
|
||||
<card-item-plugin label="单位" value="{{item.unit_ch_name}}" />
|
||||
</view>
|
||||
</card-plugin>
|
||||
<pagination-plugin curr_page="{{params.curr_page}}" page_count="{{params.page_count}}"
|
||||
total="{{count}}" bind:change="paginationChange" />
|
||||
</page-plugin>
|
||||
Reference in New Issue
Block a user