| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305 |
- import { EOrderSrc, EValidType } from "../../../constants/enum/index";
- import { FunCode } from "../../../constants/enum/funcode";
- import { sendMsgToMQ } from "../../../services/api/common/index";
- import { accountid, clientType, getErrorMsg, isEncrypted, marketid, protoHeader, timetample, userid } from "../../../services/utils";
- import { hideLoading, showLoading, showModel } from "../../../utils/message/index";
- import { isnullstr } from "../../../utils/util";
- import { queryMySellOrder, queryPermancePlanTmp } from "../../../services/api/orders/index";
- import { encryptBody } from "../../../utils/websocket/crypto";
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- /// 底部安全区域
- safeBottom: getApp().globalData.safeBottom,
- /// tabs
- tabs: [{id: 2, name: '单颗裸钻'}, {id: 5, name: '单颗彩钻'}],
- /// tab索引
- active: 0,
- /// 出售挂牌
- sellorders: <GuangZuan.MySellOrder[]>[],
- /// 选中的单据
- sellorder: <GuangZuan.MySellOrder>({}),
- /// 列头
- titles: [['重量', '形状', '尺寸', '编号'],
- ['颜色 | 净度 | 切工 | 抛光 | 对称 | 荧光 | 证书', '价格']],
- /// 显示的值
- values: [{ up: [''], dwn: [''], isChecked: false }],
- /// 是否空数据
- isEmpty: false,
- /// 当前页
- page: 1,
- /// 履约模板信息
- tmps: <GuangZuan.PermancePlanTmp[]>[],
- /// 选中履约模板
- tmp: <GuangZuan.PermancePlanTmp>({}),
- /// 是否显示
- show: false,
- /// 显示信息
- actions: [''],
- /// 颜色
- colors: ['rebeccapurple', 'green', 'hotpink', 'orange', 'darkgoldenrod', 'firebrick', 'forestgreen', 'darksalmon', 'goldenrod', 'khaki', 'rosybrown', 'sandybrown']
- },
- /**
- * 返回上层视图
- */
- backToParent() {
- /// 返回上层视图
- wx.navigateBack()
- },
- /// 显示履约模板
- showPlanTmps() {
- this.setData({ show: true })
- },
- /// 关闭
- onClose() {
- this.setData({ show: false })
- },
- onSelect(e: any) {
- /// 默认显示项
- const { index } = e.detail;
- this.setData({ tmp: this.data.tmps[index], show: false })
- },
- /**
- * 每行选中触发事件
- */
- onSelectItem(e: any) {
- var objs = this.data.values
- objs.forEach(obj => {
- obj.isChecked = false
- })
- objs[e.currentTarget.id].isChecked = true
- /// 数据赋值
- this.setData({
- values: objs,
- sellorder: this.data.sellorders[e.currentTarget.id]
- })
- },
- /**
- * tab触发事件
- */
- onTabChange(e: any) {
- /// 设置激活项
- this.setData({
- active: e.detail.index,
- /// 设置列头
- titles: this.data.tabs[e.detail.index].id === 2 ? [['重量', '形状', '尺寸', '编号'],
- ['颜色 | 净度 | 切工 | 抛光 | 对称 | 荧光 | 证书', '价格']] : [['重量', '形状', '尺寸', '编号'],
- ['颜色 | 净度 | 抛光 | 对称 | 荧光 | 证书', '价格']],
- })
- /// 查询单据信息
- this.queryMySellOrder()
- },
- /// 获取履约模板信息
- queryPermancePlanTmp() {
- /// showLoading
- showLoading(() => {
- queryPermancePlanTmp({
- success: (res) => {
- /// 获取数据
- this.setData({
- tmps: res.data,
- tmp: res.data[0],
- actions: res.data.map(obj => { return obj.templatename })
- })
- },
- complete: () => {
- /// hideLoading
- hideLoading()
- /// 停止下拉刷新
- wx.stopPullDownRefresh()
- }
- })
- })
- },
- /// 查询出售挂牌
- queryMySellOrder() {
- /// loding
- showLoading(()=>{
- /// 数据查询请求
- queryMySellOrder({
- data: {
- userid: userid(),
- zscategorys: this.data.tabs[this.data.active].id.toString()
- },
- success: (res) => {
- /// 请求失败
- if (res.code != 200) {
- /// 加载失败
- hideLoading(()=>{}, '请求失败,原因:'+res.msg)
- return
- }
- hideLoading(()=>{
- /// 设置数据
- this.setData({
- /// 设置列头
- sellorders: res.data,
- isEmpty: res.data.length === 0,
- active: 0,
- /// 显示的值
- values: res.data.map(obj => {
- return this.data.tabs[this.data.active].id === 2 ? { up: [obj.totalqty+'ct',
- isnullstr(obj.zsshapetypedisplay),
- isnullstr(obj.sizedisplay),
- obj.goodsno],
- dwn: [isnullstr(obj.zscolortype1display)+' | '+
- isnullstr(obj.zsclaritytype1display)+' | '+
- isnullstr(obj.zscuttype1display)+' | '+
- isnullstr(obj.zspolishtype1display)+' | '+
- isnullstr(obj.zssymmetrytype1display)+' | '+
- isnullstr(obj.zsfluorescencetype1display)+' | '+
- isnullstr(obj.zscerttypedisplay),
- obj.zscurrencytypedisplayunit+obj.price.toFixed(2)],
- isChecked: false } : { up: [obj.totalqty+'ct',
- isnullstr(obj.zsshapetypedisplay),
- isnullstr(obj.sizedisplay),
- obj.goodsno],
- dwn: [isnullstr(obj.zsczcolor1typedisplay)+' | '+
- isnullstr(obj.zsclaritytype1display)+' | '+
- isnullstr(obj.zspolishtype1display)+' | '+
- isnullstr(obj.zssymmetrytype1display)+' | '+
- isnullstr(obj.zsfluorescencetype1display)+' | '+
- isnullstr(obj.zscerttypedisplay),
- obj.zscurrencytypedisplayunit+obj.price.toFixed(2)],
- isChecked: false }
- })
- })
- })
- },
- fail: (emsg) => {
- /// 加载失败
- hideLoading(()=>{}, emsg)
- },
- complete: () => {
- /// 停止下拉刷新
- wx.stopPullDownRefresh()
- }
- })
- })
- },
- /// 摘卖
- doListingSell() {
- /// showModel
- showModel(() => {
- /// showLoading
- showLoading(() => {
- const { wrstandardid, wrfactortypeid, totalqty } = this.data.sellorder
- const { autoid } = this.data.tmp
- /// 请求参数
- const info = JSON.stringify({
- Header: protoHeader(FunCode.ZSSellOrderListingReq),
- UserID: userid(),
- AccountID: accountid(),
- WRStandardID: wrstandardid,
- WRFactorTypeID: wrfactortypeid,
- OrderQty: totalqty,
- PerformanceTemplateID: autoid,
- TimevalidType: EValidType.VALIDTYPE_YZ,
- OrderSrc: EOrderSrc.ORDERSRC_CLIENT,
- ClientSerialNo: timetample().toString(),
- ClientType: clientType(),
- MarketID: marketid(),
- })
- /// 发送请求
- sendMsgToMQ({
- data: {
- data: encryptBody(info),
- funCodeReq: FunCode.ZSSellOrderListingReq,
- funCodeRsp: FunCode.ZSSellOrderListingRsp,
- isEncrypted: isEncrypted()
- },
- success: (res) => {
- /// 解析对象
- const data = JSON.parse(res.data.data)
- if (data.RetCode != 0) {
- hideLoading(() => {}, getErrorMsg(data.RetCode))
- return
- }
- /// 求购发布请求成功
- hideLoading(() => {
- wx.navigateBack()
- }, '出售发布请求成功', 'success')
- },
- fail: (emsg) => {
- hideLoading(()=>{}, emsg)
- }
- })
- }, '出售请求中....')
- }, '提示', '确认要发布出售吗?')
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad() {
- /// 查询我的出售
- this.queryMySellOrder()
- /// 获取履约模板信息
- this.queryPermancePlanTmp()
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- /// 查询我的出售
- this.queryMySellOrder()
- /// 获取履约模板信息
- this.queryPermancePlanTmp()
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- }
- })
|