select-goods.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888
  1. /*******************************************************************************
  2. * Copyright(c) 2022 dongke All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:
  5. * 2.功能描述:商品选择
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 于继渤 2022-05-13 1.00
  9. *******************************************************************************/
  10. const api = require('../../../utils/api.js');
  11. const Constants = require('../../../utils/Constants.js');
  12. import Dialog from '../../../dist/dialog/dialog.js';
  13. const common = require('../../../utils/common.js');
  14. const chooseGoodsCommon = require('../../../utils/chooseGoodsCommon.js');
  15. const app = getApp()
  16. Page({
  17. /**
  18. * 页面的初始数据
  19. */
  20. data: {
  21. nonStandardListFlag: true,
  22. skuloading: false,
  23. specsId: undefined,
  24. orderType: '',
  25. followFlag: false, // 退换补标识
  26. loading: false,
  27. list: [],
  28. pageInfo: {
  29. pageSize: 10,
  30. currentPage: 1
  31. },
  32. noMore: false,
  33. choosedGoodsList: [], //已选商品列表
  34. choosedGoodsListLength: 0,
  35. goodsList: [], //商品列表
  36. goodsSkuList: [], //SPU对应的SKU
  37. //------------------------
  38. sumGoodsAmount: '0', //合计金额
  39. sumQuantity: '0', // 合计数量
  40. categoryQuantity: 0, // 品类数
  41. mainActiveIndex: 0,
  42. numNum: 0,
  43. sideKey: 0,
  44. search: '',
  45. noMore: false,
  46. loading: false,
  47. pageInfo: {
  48. pageSize: 10,
  49. currentPage: 1
  50. },
  51. active: 0,
  52. specsActive: -1, // 个别分类
  53. showAdd: false,
  54. showChoosed: false,
  55. showAllSpecs: false, // 是否显示商品分类
  56. updateIndex: null,
  57. skuData: [], // 根据spuId查询出的sku信息
  58. defSkuId: 0, // 默认的skuId
  59. // 商品分类
  60. typeList: [{
  61. name: "全部分类",
  62. id: ''
  63. },
  64. {
  65. name: "促销套餐",
  66. id: 0
  67. },
  68. ],
  69. // sku规格
  70. skuSpecsList: [],
  71. // 可用的sku规格
  72. skuSpecsData: [],
  73. // 坑距
  74. formKG: [{
  75. title: '',
  76. tags: [],
  77. }],
  78. //单品促销
  79. PricePromotionData: [],
  80. tagList: [{
  81. id: 1,
  82. name: '原木柜'
  83. },
  84. {
  85. id: 2,
  86. name: '古典柜'
  87. }, {
  88. id: 3,
  89. name: '金属柜'
  90. }, {
  91. id: 4,
  92. name: '生态柜'
  93. },
  94. {
  95. id: 0,
  96. name: '更多'
  97. },
  98. ],
  99. infoTypeFlag: false,
  100. infoTypeFlag1: false,
  101. show_spec: false,
  102. show_glassParameters: false,
  103. },
  104. changeTag(e) {
  105. this.setData({
  106. active: e.detail.index
  107. })
  108. },
  109. /**
  110. * 允许从相机和相册扫码
  111. * @param {*} e
  112. */
  113. scanQRCode(e) {
  114. // 允许从相机和相册扫码
  115. wx.scanCode({
  116. success(res) {
  117. let scancode = res.result
  118. // 调转商品选品
  119. wx.navigateTo({
  120. url: '../choose-goods/choose-goods?searchText=' + scancode.length > 14 ? scancode.substring(0, 14) : scancode,
  121. })
  122. }
  123. })
  124. },
  125. /**
  126. * @desc : 改变标识
  127. * @author : 周兴
  128. * @date : 2022/8/6 17:16
  129. */
  130. changeAllReadyCheckBox(e) {
  131. chooseGoodsCommon.changeAllReadyCheckBoxCommon(e, this)
  132. },
  133. /**
  134. * @desc : 分类切换
  135. * @author : 于继渤
  136. * @date : 2022/5/26 20:16
  137. */
  138. changeSidebar(e) {
  139. let id = this.data.typeList[e.detail].id
  140. if (id == "" && typeof (id) != 'number') {
  141. this.setData({
  142. sideKey: null,
  143. specsId: null
  144. })
  145. } else {
  146. this.setData({
  147. sideKey: e.detail,
  148. specsId: id
  149. })
  150. }
  151. this.setData({
  152. searchText: ''
  153. })
  154. // 查询
  155. this.doSearch()
  156. },
  157. /**
  158. * @desc : 打开商品
  159. * @author : 周兴
  160. * @date : 2022/7/2 20:16
  161. */
  162. openAddItemInfo(e) {
  163. // chooseGoodsCommon.openAddItemInfoCommon(e, this, 'choose-goods')
  164. let item = e.currentTarget.dataset.item
  165. this.setData({
  166. currentChoosedItem: item,
  167. showAdd: true,
  168. show1: true,
  169. show2: false,
  170. show3: false,
  171. show4: false,
  172. show5: false
  173. })
  174. },
  175. /**
  176. * 关闭产品
  177. * @param {*} e
  178. */
  179. closeAddItemInfo() {
  180. chooseGoodsCommon.closeAddItemInfoCommon(this)
  181. },
  182. /**
  183. * @desc : 打开选择明细
  184. * @author : 周兴
  185. * @date : 2022/7/4 20:16
  186. */
  187. openChoosedItemInfo(e) {
  188. chooseGoodsCommon.openChoosedItemInfoCommon(e, this)
  189. },
  190. /**
  191. * @desc : 删除选中的数据
  192. * @author : 周兴
  193. * @date : 2022/7/4 20:16
  194. */
  195. delChoosedGoodsItem(e) {
  196. chooseGoodsCommon.delChoosedGoodsItemCommon(e, this, false)
  197. let choosedGoodsListLength = this.data.choosedGoodsListLength
  198. if (choosedGoodsListLength == 0) {
  199. wx.disableAlertBeforeUnload({
  200. success: (e) => {
  201. },
  202. fail: (e) => {
  203. }
  204. })
  205. }
  206. },
  207. /**
  208. * @desc : 确定
  209. * @date : 2022/7/5 16:49
  210. * @author : 周兴
  211. */
  212. submit() {
  213. let choosedGoodsList = this.data.choosedGoodsList
  214. // wx.navigateTo({
  215. // url: '../order-billing/add/add?choosedGoodsList=' + encodeURIComponent(JSON.stringify(choosedGoodsList)) ,
  216. // })
  217. const eventChannel = this.getOpenerEventChannel();
  218. let url = null;
  219. // 接收父页面传递的参数
  220. eventChannel.on('params', function (data) {
  221. url = data.url
  222. })
  223. // 从开单界面点击选择
  224. if(!url){
  225. eventChannel.emit('bindData',choosedGoodsList)
  226. wx.navigateBack({
  227. delta: 1
  228. })
  229. }else{
  230. // 开单直接打开
  231. wx.navigateTo({
  232. url: url,
  233. success: function (res) {
  234. // 通过eventChannel向被打开页面传送数据
  235. console.log('bbbb3',choosedGoodsList);
  236. res.eventChannel.emit('choose', { data: choosedGoodsList })
  237. }
  238. })
  239. }
  240. },
  241. /**
  242. * @desc : 查询
  243. * @date : 2022/5/12 16:49
  244. * @author : 于继渤
  245. */
  246. doSearch() {
  247. let pageInfo = this.data.pageInfo;
  248. pageInfo.pageSize = 10;
  249. pageInfo.currentPage = 1;
  250. this.setData({
  251. show: false,
  252. noMore: false,
  253. pageInfo: pageInfo,
  254. list: [],
  255. goodsList: []
  256. })
  257. this.getData()
  258. },
  259. onSearchText(e) {
  260. this.setData({
  261. searchText: e.detail,
  262. sideKey: 0,
  263. specsId: null
  264. })
  265. },
  266. /**
  267. * @desc : 获取商品数据
  268. * @date : 2022/5/13 16:49
  269. * @author : 于继渤
  270. */
  271. getData(e) {
  272. let tList = [{
  273. activityId: 84,
  274. activityName: "零售活动方案",
  275. desc: "零售活动方案",
  276. id: "d2f69c53-a5ba-4414-86ee-3b05849cb882",
  277. orderItemQuantity: 1,
  278. pathType: 1,
  279. pricePromotion: 70000,
  280. priceSale: 70000,
  281. promotionId: 283,
  282. promotionName: "套餐相同商品",
  283. promotionPriceType: -2,
  284. promotionPriceTypeName: "正价产品",
  285. promotionType: 2,
  286. promotionTypeName: "组合促销",
  287. seq: 1,
  288. spuModel: "套餐相同商品",
  289. standardId: 308,
  290. title: "套餐相同商品",
  291. titleTag: "组合促销"
  292. }, {
  293. activityId: 84,
  294. activityName: "零售活动方案",
  295. desc: "零售活动方案",
  296. id: "f911da02-2b9a-400c-813b-8007bf994856",
  297. orderItemQuantity: 1,
  298. pathType: 1,
  299. pricePromotion: 8600,
  300. priceSale: 8600,
  301. promotionId: 273,
  302. promotionName: "1115新活动",
  303. promotionPriceType: -2,
  304. promotionPriceTypeName: "正价产品",
  305. promotionType: 2,
  306. promotionTypeName: "组合促销",
  307. seq: 2,
  308. spuModel: "1115新活动",
  309. standardId: 308,
  310. title: "1115新活动",
  311. titleTag: "组合促销"
  312. }, {
  313. activityId: 84,
  314. activityName: "零售活动方案",
  315. desc: "零售活动方案",
  316. id: "a2708ff8-4032-40a2-8823-5176a0e92b84",
  317. orderItemQuantity: 1,
  318. pathType: 1,
  319. pricePromotion: 13000,
  320. priceSale: 13000,
  321. promotionId: 271,
  322. promotionName: "零售套餐001",
  323. promotionPriceType: -2,
  324. promotionPriceTypeName: "正价产品",
  325. promotionType: 2,
  326. promotionTypeName: "组合促销",
  327. seq: 3,
  328. spuModel: "零售套餐001",
  329. standardId: 308,
  330. title: "零售套餐001",
  331. titleTag: "组合促销"
  332. }];
  333. this.setData({
  334. list: tList,
  335. goodsList: tList
  336. })
  337. },
  338. /**
  339. * 数量的变化事件
  340. * @param {*} e
  341. */
  342. changeAllreadyChooseQuantityPop(e) {
  343. let currentChoosedItem = this.data.currentChoosedItem
  344. currentChoosedItem.itemQuantity = e.detail
  345. if (currentChoosedItem.nonStandardArea) {
  346. currentChoosedItem.itemAmount = Number(currentChoosedItem.priceSale * currentChoosedItem.itemQuantity * currentChoosedItem.nonStandardArea).toFixed(2)
  347. currentChoosedItem.itemAmount = isNaN(currentChoosedItem.itemAmount) ? 0 : currentChoosedItem.itemAmount
  348. } else {
  349. currentChoosedItem.itemAmount = Number(currentChoosedItem.priceSale * currentChoosedItem.itemQuantity).toFixed(2)
  350. currentChoosedItem.itemAmount = isNaN(currentChoosedItem.itemAmount) ? 0 : currentChoosedItem.itemAmount
  351. }
  352. this.setData({
  353. currentChoosedItem: currentChoosedItem
  354. })
  355. },
  356. /**
  357. * @desc : 生命周期函数--监听页面加载
  358. * @date : 2022/5/13 16:49
  359. * @author : 于继渤
  360. */
  361. onLoad: function (options) {
  362. let that = this
  363. // 调用监听器,监听数据变化
  364. this.watch(this.data, {
  365. choosedGoodsListLength: function (newVal) {
  366. if (newVal != 0) {
  367. that.BeaforeUnLoad()
  368. console.log('调用监听器,监听数据变化')
  369. }
  370. }
  371. })
  372. if (options.customerId) {
  373. this.setData({
  374. customerId: parseInt(options.customerId)
  375. })
  376. }
  377. if (options.orgId) {
  378. this.setData({
  379. orgId: parseInt(options.orgId)
  380. })
  381. }
  382. let _this = this;
  383. wx.getSystemInfo({
  384. success: function (res) {
  385. _this.setData({
  386. windowHeight: res.windowHeight,
  387. windowWidth: res.windowWidth
  388. })
  389. }
  390. })
  391. //设置来源
  392. if (options.orderType) {
  393. this.setData({
  394. orderType: options.orderType
  395. })
  396. }
  397. // 是否是退换补单(退换补单按照实际量进行处理)
  398. if (options.followFlag) {
  399. this.setData({
  400. followFlag: options.followFlag,
  401. orgId: Number(options.orgId)
  402. })
  403. }
  404. //预算报价客户信息
  405. if (options.customerItem) {
  406. this.setData({
  407. customerItem: JSON.parse(decodeURIComponent(options.customerItem))
  408. })
  409. }
  410. //扫码搜索
  411. if (options.searchText) {
  412. this.setData({
  413. searchText: options.searchText
  414. })
  415. }
  416. //哪个界面 进来的
  417. if (options.page) {
  418. this.setData({
  419. page: options.page
  420. })
  421. }
  422. //执行查询
  423. this.doSearch()
  424. this.getGoodsClassification()
  425. },
  426. /**
  427. * @desc : 清空default
  428. * @date : 2022/7/4 16:49
  429. * @author : 周兴
  430. */
  431. clearDefault() {
  432. chooseGoodsCommon.clearDefaultCommon(this);
  433. },
  434. /**
  435. * @desc : 加载商品分类
  436. * @date : 2022/5/15 16:49
  437. * @author : 于继渤
  438. */
  439. getGoodsClassification() {
  440. let typeList = [{
  441. id: null,
  442. name: "全部分类"
  443. },
  444. {
  445. id: 0,
  446. name: "促销套餐"
  447. },
  448. {
  449. id: 64,
  450. name: "智能马桶"
  451. },
  452. {
  453. id: 96,
  454. name: "坐便器"
  455. },
  456. {
  457. id: 138,
  458. name: "电控坐便器"
  459. },
  460. {
  461. id: 79,
  462. name: "蹲便器"
  463. },
  464. {
  465. id: 104,
  466. name: "小便器"
  467. },
  468. {
  469. id: 105,
  470. name: "洗面器"
  471. },
  472. {
  473. id: 93,
  474. name: "其它陶瓷"
  475. },
  476. {
  477. id: 66,
  478. name: "浴室柜"
  479. },
  480. ]
  481. this.setData({
  482. typeList: typeList
  483. })
  484. },
  485. /**
  486. * @desc : 选择数据
  487. * @date : 2022/7/4 16:49
  488. * @author : 周兴
  489. */
  490. chooseSkuInfo() {
  491. let currentChoosedItemTemp = {
  492. ...this.data.currentChoosedItem
  493. }
  494. let choosedGoodsList = this.data.choosedGoodsList
  495. choosedGoodsList.push(currentChoosedItemTemp)
  496. this.setData({
  497. choosedGoodsList,
  498. showAdd: false
  499. })
  500. },
  501. /**
  502. * @desc : 已选商品更改数量计算合计
  503. * @date : 2022/7/4 16:49
  504. * @author : 周兴
  505. */
  506. changeAllreadyChooseQuantity(e) {
  507. let choosedGoodsList = this.data.choosedGoodsList
  508. let index = e.currentTarget.dataset.index
  509. choosedGoodsList[index].itemQuantity = e.detail ? Number(e.detail) : 0
  510. choosedGoodsList[index].itemAmount = Number(choosedGoodsList[index].priceSale * choosedGoodsList[index].itemQuantity)
  511. this.setData({
  512. choosedGoodsList: choosedGoodsList,
  513. })
  514. // 计算合计金额
  515. chooseGoodsCommon.getSumAmount(this);
  516. },
  517. /**
  518. * @desc : 标价折扣输入事件
  519. * @author : 于继渤
  520. * @date : 2022/5/31 17:16
  521. */
  522. changeDiscountStandardField(e) {
  523. let currentChoosedItem = this.data.currentChoosedItem
  524. currentChoosedItem.discountStandard = e.detail
  525. this.setData({
  526. currentChoosedItem: currentChoosedItem
  527. })
  528. },
  529. /**
  530. * @desc : 销售价格编辑
  531. * @author : 常皓宁
  532. * @date : 2022/5/31 14:45
  533. */
  534. changeSalesPriceField(e) {
  535. let priceSale = e.detail.value;
  536. //优惠卷(标价负数)
  537. if (this.data.currentChoosedItem.priceStandard < 0 || this.data.currentChoosedItem.pricePromotion < 0) {
  538. priceSale = Number(0 - e.detail.value)
  539. }
  540. chooseGoodsCommon.changeSalesPriceCommon(priceSale, this, false)
  541. },
  542. /**
  543. * @desc : 修改销售价格
  544. * @author : 周兴
  545. * @date : 2022/7/6 14:45
  546. */
  547. changeSalesPrice(priceSale) {
  548. chooseGoodsCommon.changeSalesPriceCommon(priceSale, this, true)
  549. },
  550. /**
  551. * @desc : 修改销售金额
  552. * @author : 周兴
  553. * @date : 2022/7/4 14:45
  554. */
  555. changeItemAmountField(e) {
  556. chooseGoodsCommon.changeItemAmountFieldCommon(e, this)
  557. },
  558. /**
  559. * @desc : 切换sku商品规格
  560. * @author : 周兴
  561. * @date : 2022/6/1 10:16
  562. */
  563. changeSkuSpecs(e) {
  564. chooseGoodsCommon.changeSkuSpecsCommon(e, this);
  565. },
  566. /**
  567. * @desc : 主柜规格单选
  568. * @author : 于继渤
  569. * @date : 2022/6/02 16:16
  570. */
  571. clickZGGG(e) {
  572. let itemt = e.target.dataset.itemt;
  573. let pindex = e.target.dataset.pindex;
  574. let indext = e.target.dataset.indext;
  575. let formZGGG = this.data.formZGGG
  576. let infotype = formZGGG[pindex].tags[indext].infotype
  577. infotype = 'default'
  578. formZGGG[pindex].tags.forEach(res => {
  579. res.infotype = 'default'
  580. })
  581. if (infotype == 'default') {
  582. infotype = 'info'
  583. } else {
  584. infotype = 'default'
  585. }
  586. formZGGG[pindex].tags[indext].infotype = infotype
  587. this.setData({
  588. formZGGG
  589. })
  590. },
  591. /**
  592. * @desc : 定制品单选
  593. * @author : 于继渤
  594. * @date : 2022/6/02 16:16
  595. */
  596. clickDZP(e) {
  597. let itemt = e.target.dataset.itemt;
  598. let pindex = e.target.dataset.pindex;
  599. let indext = e.target.dataset.indext;
  600. let formDZP = this.data.formDZP
  601. let infotype = formDZP[pindex].tags[indext].infotype
  602. infotype = 'default'
  603. formDZP[pindex].tags.forEach(res => {
  604. res.infotype = 'default'
  605. })
  606. if (infotype == 'default') {
  607. infotype = 'info'
  608. } else {
  609. infotype = 'default'
  610. }
  611. formDZP[pindex].tags[indext].infotype = infotype
  612. this.setData({
  613. formDZP
  614. })
  615. },
  616. /**
  617. * @desc : 切换组合促销明细
  618. * @date : 2022/7/5 16:49
  619. * @author : 周兴
  620. */
  621. changeCombinedItem(e) {
  622. chooseGoodsCommon.changeCombinedItemCommon(e, this)
  623. },
  624. /**
  625. * @desc : 单品促销单选
  626. * @author : 于继渤
  627. * @date : 2022/6/02 16:16
  628. */
  629. clickDP(e) {
  630. chooseGoodsCommon.clickDPCommon(e, this)
  631. },
  632. /**
  633. * @desc : 使用位置相关事件
  634. * @author : 于继渤
  635. * @date : 2022/5/26 12:16
  636. */
  637. changeUseLocation(e) {
  638. let currentChoosedItem = this.data.currentChoosedItem
  639. currentChoosedItem.usedLocation = e.detail
  640. this.setData({
  641. currentChoosedItem: currentChoosedItem
  642. })
  643. },
  644. /**
  645. * @desc : 点击全部分类
  646. * @date : 2022/7/8 16:49
  647. * @author : 周兴
  648. */
  649. clickAllSpecs() {
  650. // 让其他分类的标识置为-1
  651. this.setData({
  652. specsActive: -1,
  653. specsId: null
  654. })
  655. // 查询数据
  656. this.doSearch()
  657. },
  658. /**
  659. * @desc : 点击全部单个分类
  660. * @date : 2022/7/8 16:49
  661. * @author : 周兴
  662. */
  663. changeSpecsTabs(e) {
  664. let index = e.detail.index;
  665. this.setData({
  666. specsActive: index,
  667. })
  668. let id = this.data.typeList[index].id
  669. this.setData({
  670. specsId: id
  671. })
  672. // 查询数据
  673. this.doSearch()
  674. },
  675. /**
  676. * @desc : 是否显示商品分类页面
  677. * @date : 2022/7/9 16:49
  678. * @author : 周兴
  679. */
  680. displayAllSpecs() {
  681. this.setData({
  682. showAllSpecs: true
  683. })
  684. },
  685. /**
  686. * @desc : 页面上拉触底事件的处理函数
  687. * @author : 周兴
  688. * @date : 2022/8/1 12:16
  689. */
  690. scrollToLower() {
  691. if (this.data.loading || this.data.noMore) {
  692. return;
  693. }
  694. this.setData({
  695. pageInfo: {
  696. pageSize: this.data.pageInfo.pageSize,
  697. currentPage: this.data.pageInfo.currentPage + 1
  698. }
  699. })
  700. this.getData('more')
  701. },
  702. /**
  703. * @desc : 页面上拉触底事件的处理函数
  704. * @author : 于继渤
  705. * @date : 2022/5/24 12:16
  706. */
  707. onReachBottom: function () {
  708. if (this.data.loading || this.data.noMore || this.data.active == 1) {
  709. return;
  710. }
  711. this.setData({
  712. pageInfo: {
  713. pageSize: this.data.pageInfo.pageSize,
  714. currentPage: this.data.pageInfo.currentPage + 1
  715. }
  716. })
  717. this.getData('more')
  718. },
  719. BeaforeUnLoad() {
  720. wx.enableAlertBeforeUnload({
  721. message: '离开此页后已选商品将会被清空哦',
  722. success: (e) => {
  723. wx.setStorageSync('choosedGoodsList', [])
  724. },
  725. fail: (e) => {
  726. }
  727. })
  728. },
  729. // 设置监听器
  730. watch: function (ctx, obj) {
  731. Object.keys(obj).forEach(key => {
  732. this.observer(ctx, key, ctx[key], function (value) {
  733. obj[key].call(ctx, value)
  734. })
  735. })
  736. },
  737. // 监听属性,并执行监听函数
  738. observer: function (data, key, val, fn) {
  739. Object.defineProperty(data, key, {
  740. configurable: true,
  741. enumerable: true,
  742. get: function () {
  743. return val
  744. },
  745. set: function (newVal) {
  746. if (newVal === val) return
  747. fn && fn(newVal)
  748. val = newVal
  749. },
  750. })
  751. },
  752. /**
  753. * @desc : 选择非标参数事件
  754. * @author : 于继渤
  755. * @date : 2022/8/24 13:16
  756. */
  757. nonStandardTap(e) {
  758. chooseGoodsCommon.nonStandardTap(e, this)
  759. },
  760. /**
  761. * @desc : 设置非标匹配参数
  762. * @author : 于继渤
  763. * @date : 2022/8/24 13:16
  764. */
  765. setNonStandardMatchingParameters() {
  766. chooseGoodsCommon.setNonStandardMatchingParameters(e, this)
  767. },
  768. /**
  769. * @desc : 非标商品选择事件
  770. * @author : 于继渤
  771. * @date : 2022/8/24 13:16
  772. */
  773. nonGlassSpuItemsTap(e) {
  774. chooseGoodsCommon.nonGlassSpuItemsTap(e, this)
  775. },
  776. /**
  777. * @desc : 非标商品非标参数输入事件
  778. * @author : 于继渤
  779. * @date : 2022/8/24 13:16
  780. */
  781. bindInputIsScopeOne(e) {
  782. chooseGoodsCommon.bindInputIsScopeOne(e, this)
  783. },
  784. bindBlurIsScopeOne(e) {
  785. chooseGoodsCommon.bindBlurIsScopeOne(e, this)
  786. },
  787. changeFlgAllowSpecsUndefine(e) {
  788. let currentChoosedItem = this.data.currentChoosedItem
  789. currentChoosedItem.flgSpecsUndefine = e.detail
  790. this.setData({
  791. currentChoosedItem: currentChoosedItem
  792. })
  793. },
  794. bindInputNonStantardArea(e) {
  795. chooseGoodsCommon.bindInputNonStantardArea(e, this)
  796. },
  797. //面积离焦
  798. bindBlurNonStantardArea(e) {
  799. chooseGoodsCommon.bindBlurNonStantardArea(e, this)
  800. },
  801. onUnload() {
  802. Dialog.confirm({
  803. message: '哈哈哈哈哈哈',
  804. }).then(() => {
  805. })
  806. },
  807. /**
  808. * @desc : 计算折扣反算销售价格
  809. * @author : 于继渤
  810. * @date : 2022/7/4 14:45
  811. */
  812. changeDiscountField(e) {
  813. chooseGoodsCommon.changeDiscountFieldCommon(e, this)
  814. }
  815. })