addstock.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  1. // pages/stock/addstock/addstock.js
  2. let util = require('../../../utils/util.js');
  3. let dateTimePicker = require('../../../utils/dateTimePicker.js');
  4. var that
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. id: 0,
  11. onlyid: 0,
  12. allgood: [],
  13. cover: false,
  14. isgoods: false,
  15. goodname: '',
  16. goodid: 0,
  17. goodonlyid: 0,
  18. goodtypename: '',
  19. goodtypeid: 0,
  20. goodtypeonlyid: 0,
  21. goodsCode: '',
  22. goodsBarcode: '',
  23. purchasePrice: 0,
  24. purchaseNumber: 0,
  25. payWayarray: [],
  26. payWayindex: 0,
  27. payWay: 1,
  28. suppliers: [],
  29. supplierid: 0,
  30. supplieronlyid: 0,
  31. suppliername: '请选择',
  32. prices1: 0,
  33. submitDate: '请选择',
  34. productionDate: '请选择',
  35. begoodTime: '请选择',
  36. images: [],
  37. imagessize: 0,
  38. imgBaseUrl: util.baseImgUrl,
  39. idx: 0,
  40. factory: '',
  41. explains: '',
  42. imgurl: util.imgurl,
  43. needpay: 0,
  44. realPayMoney: 0,
  45. sellPrice: 0,
  46. prices1: 0,
  47. prices2: 0,
  48. prices3: 0,
  49. prices4: 0,
  50. prices5: 0,
  51. isrealPayMoney: false,
  52. startYear: 1900,
  53. endYear: 2999
  54. },
  55. changeDateTime(e) {
  56. this.setData({
  57. dateTime: e.detail.value
  58. });
  59. },
  60. changeDateTimeColumn(e) {
  61. this.dateUpdate(e.detail.column, e.detail.value)
  62. },
  63. dateUpdate(column, value) {
  64. var arr = this.data.dateTime,
  65. dateArr = this.data.dateTimeArray;
  66. arr[column] = value;
  67. dateArr[2] = dateTimePicker.getMonthDay(dateArr[0][arr[0]], dateArr[1][arr[1]]);
  68. this.setData({
  69. dateTimeArray: dateArr,
  70. dateTime: arr
  71. });
  72. },
  73. changeDateTime1(e) {
  74. this.setData({
  75. dateTime1: e.detail.value
  76. });
  77. },
  78. changeDateTimeColumn1(e) {
  79. this.dateUpdate1(e.detail.column, e.detail.value)
  80. },
  81. dateUpdate1(column, value) {
  82. var arr = this.data.dateTime1,
  83. dateArr = this.data.dateTimeArray1;
  84. arr[column] = value;
  85. dateArr[2] = dateTimePicker.getMonthDay(dateArr[0][arr[0]], dateArr[1][arr[1]]);
  86. this.setData({
  87. dateTimeArray1: dateArr,
  88. dateTime1: arr
  89. });
  90. },
  91. changeDateTime2(e) {
  92. this.setData({
  93. dateTime2: e.detail.value
  94. });
  95. },
  96. changeDateTimeColumn2(e) {
  97. this.dateUpdate2(e.detail.column, e.detail.value)
  98. },
  99. dateUpdate2(column, value) {
  100. var arr = this.data.dateTime2,
  101. dateArr = this.data.dateTimeArray2;
  102. arr[column] = value;
  103. dateArr[2] = dateTimePicker.getMonthDay(dateArr[0][arr[0]], dateArr[1][arr[1]]);
  104. this.setData({
  105. dateTimeArray2: dateArr,
  106. dateTime2: arr
  107. });
  108. },
  109. getSet() {
  110. util.query('userSetting/wxapi/getMySetting', {}, function(res) {
  111. if (res.code === 10000) {
  112. that.setData({
  113. setting: res.data
  114. })
  115. } else {
  116. util.showToast('获取失败')
  117. }
  118. })
  119. },
  120. scan() {
  121. wx.scanCode({
  122. success(res) {
  123. console.log(res)
  124. if (res && res.errMsg === 'scanCode:ok') {
  125. that.setData({
  126. goodsBarcode: res.result
  127. })
  128. } else {
  129. util.showToast('未识别出正确的条码')
  130. }
  131. },
  132. fail(res) {
  133. console.log(res)
  134. util.showToast('未识别出正确的条码')
  135. }
  136. })
  137. },
  138. savegoodsBatch() {
  139. var data = {
  140. goods: {
  141. id: this.data.goodid,
  142. onlyID: this.data.goodonlyid
  143. },
  144. goodsCode: this.data.goodsCode,
  145. goodsBarcode: this.data.goodsBarcode,
  146. purchasePrice: this.data.purchasePrice,
  147. purchaseNumber: this.data.purchaseNumber,
  148. payWay: this.data.payWay,
  149. prices1: this.data.prices1,
  150. prices2: this.data.prices2,
  151. prices3: this.data.prices3,
  152. prices4: this.data.prices4,
  153. prices5: this.data.prices5,
  154. sellPrice: this.data.sellPrice,
  155. submitDate: this.data.dateTimeArray[0][this.data.dateTime[0]] + '-' + this.data.dateTimeArray[1][this.data.dateTime[1]] + '-' + this.data.dateTimeArray[2][this.data.dateTime[2]] + ' ' + this.data.dateTimeArray[3][this.data.dateTime[3]] + ':' + this.data.dateTimeArray[4][this.data.dateTime[4]] + ':' + this.data.dateTimeArray[5][this.data.dateTime[5]],
  156. productionDate: this.data.dateTimeArray1[0][this.data.dateTime1[0]] + '-' + this.data.dateTimeArray1[1][this.data.dateTime1[1]] + '-' + this.data.dateTimeArray1[2][this.data.dateTime1[2]] + ' ' + this.data.dateTimeArray1[3][this.data.dateTime1[3]] + ':' + this.data.dateTimeArray1[4][this.data.dateTime1[4]] + ':' + this.data.dateTimeArray1[5][this.data.dateTime1[5]],
  157. begoodTime: this.data.dateTimeArray2[0][this.data.dateTime2[0]] + '-' + this.data.dateTimeArray2[1][this.data.dateTime2[1]] + '-' + this.data.dateTimeArray2[2][this.data.dateTime2[2]] + ' ' + this.data.dateTimeArray2[3][this.data.dateTime2[3]] + ':' + this.data.dateTimeArray2[4][this.data.dateTime2[4]] + ':' + this.data.dateTimeArray2[5][this.data.dateTime2[5]],
  158. image: this.data.images.length > 0 ? this.data.images[0] : '',
  159. realPayMoney: this.data.realPayMoney,
  160. factory: this.data.factory,
  161. explains: this.data.explains,
  162. image: this.data.images.length > 0 ? this.data.images[0] : ''
  163. }
  164. if (this.data.supplierid && this.data.supplierid != 0) {
  165. data.supplier = {
  166. id: this.data.supplierid,
  167. onlyID: this.data.supplieronlyid
  168. }
  169. }
  170. var url = ''
  171. if (this.data.id) {
  172. url = 'goodsbatch/wxapi/update'
  173. data.id = this.data.id
  174. data.onlyID = this.data.onlyid
  175. data = Object.assign(this.data.olddata, data)
  176. } else {
  177. url = 'goodsbatch/wxapi/create'
  178. }
  179. util.query(url, data, function(res) {
  180. if (res.code === 10000) {
  181. util.showToast('保存成功')
  182. setTimeout(function() {
  183. wx.navigateBack({
  184. delta: 1
  185. })
  186. }, 2000)
  187. } else {
  188. util.showToast('保存失败')
  189. }
  190. }, 'POST')
  191. },
  192. save() {
  193. if (this.data.goodid) {
  194. this.savegoodsBatch()
  195. } else {
  196. this.saveGoods()
  197. }
  198. },
  199. saveGoods() {
  200. if (!this.data.goodname) {
  201. util.showToast('请输入商品名称')
  202. return
  203. }
  204. if (!this.data.goodtypeid && this.data.setting.goodsCategory === 1) {
  205. util.showToast('请选择商品分类')
  206. return
  207. }
  208. var data = {
  209. name: this.data.goodname
  210. }
  211. if (this.data.goodtypeid) {
  212. data.goodsCategory = {
  213. id: this.data.goodtypeid,
  214. onlyID: this.data.goodtypeonlyid
  215. }
  216. }
  217. util.query('goods/wxapi/create', data, function(res) {
  218. if (res.code === 10000) {
  219. that.setData({
  220. goodid: res.goodsId,
  221. goodonlyid: res.goodsOnlyId
  222. })
  223. that.save()
  224. } else {
  225. util.showToast('保存失败')
  226. }
  227. }, 'POST')
  228. },
  229. addImage(e) {
  230. var idx = e.target.dataset.idx
  231. console.log(idx)
  232. wx.chooseImage({
  233. count: idx == -1 ? (1 - that.data.images.length) : 1, // 默认9
  234. sizeType: ['compressed'],
  235. sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
  236. success: function(res) {
  237. console.log(res.tempFilePaths);
  238. wx.showLoading({
  239. title: '加载中',
  240. })
  241. for (var i in res.tempFilePaths) {
  242. wx.uploadFile({
  243. url: util.baseurl + 'file/uploadfile',
  244. filePath: res.tempFilePaths[i],
  245. name: 'file',
  246. header: {
  247. 'token': wx.getStorageSync("token")
  248. },
  249. success: function(res) {
  250. wx.hideLoading()
  251. var d = JSON.parse(res.data);
  252. if (d.code == 10000) {
  253. var images = that.data.images;
  254. if (idx == -1) {
  255. images.push(d.imageUrl)
  256. } else {
  257. images[idx] = d.imageUrl
  258. }
  259. that.setData({
  260. images: images,
  261. isblank: false
  262. })
  263. that.setData({
  264. imagessize: that.data.images.length
  265. })
  266. }
  267. }
  268. })
  269. }
  270. }
  271. })
  272. },
  273. tochoisetype(e) {
  274. wx.navigateTo({
  275. url: '/pages/stock/goodstype/goodstype',
  276. })
  277. },
  278. setsellPrice(e) {
  279. this.setData({
  280. sellPrice: util.PointNum(e.detail.value)
  281. })
  282. },
  283. setprices5(e) {
  284. this.setData({
  285. prices5: util.PointNum(e.detail.value)
  286. })
  287. },
  288. setprices4(e) {
  289. this.setData({
  290. prices4: util.PointNum(e.detail.value)
  291. })
  292. },
  293. setprices3(e) {
  294. this.setData({
  295. prices3: util.PointNum(e.detail.value)
  296. })
  297. },
  298. setprices2(e) {
  299. this.setData({
  300. prices2: util.PointNum(e.detail.value)
  301. })
  302. },
  303. setprices1(e) {
  304. this.setData({
  305. prices1: util.PointNum(e.detail.value)
  306. })
  307. },
  308. setfactory(e) {
  309. this.setData({
  310. factory: e.detail.value
  311. })
  312. },
  313. setexplains(e) {
  314. this.setData({
  315. explains: e.detail.value
  316. })
  317. },
  318. setbegoodTime(e) {
  319. this.setData({
  320. begoodTime: e.detail.value
  321. })
  322. },
  323. setproductionDate(e) {
  324. this.setData({
  325. productionDate: e.detail.value
  326. })
  327. },
  328. setsubmitDate(e) {
  329. this.setData({
  330. submitDate: e.detail.value
  331. })
  332. },
  333. bindsupplierChange(e) {
  334. this.setData({
  335. supplierindex: e.detail.value,
  336. supplierid: this.data.suppliers[e.detail.value].id,
  337. supplieronlyid: this.data.suppliers[e.detail.value].onlyID,
  338. suppliername: this.data.suppliers[e.detail.value].name
  339. })
  340. },
  341. getSupplierListData() {
  342. util.query("supplier/wxapi/list", {}, function(res) {
  343. if (res.code === 10000) {
  344. var da = []
  345. res.data.forEach(function(e) {
  346. da.push({
  347. id: e.supplier.id,
  348. name: e.supplier.name,
  349. onlyID: e.supplier.onlyID
  350. })
  351. })
  352. that.setData({
  353. suppliers: da
  354. })
  355. } else {
  356. that.setData({
  357. suppliers: []
  358. })
  359. }
  360. })
  361. },
  362. setrealPayMoney(e) {
  363. var price = util.PointNum(e.detail.value)
  364. this.setData({
  365. realPayMoney: (this.data.purchasePrice * this.data.purchaseNumber < price) ? parseFloat(this.data.purchasePrice * this.data.purchaseNumber).toFixed(2) : price,
  366. needpay: (this.data.purchasePrice * this.data.purchaseNumber < e.detail.value) ? 0 : parseFloat(this.data.purchasePrice * this.data.purchaseNumber - e.detail.value).toFixed(2),
  367. isrealPayMoney: true
  368. })
  369. },
  370. payWayChange(e) {
  371. this.setData({
  372. payWayindex: e.detail.value,
  373. payWay: this.data.payWayarray[e.detail.value].key
  374. })
  375. },
  376. setpurchaseNumber(e) {
  377. var price = util.PointNum(e.detail.value)
  378. this.setData({
  379. purchaseNumber: price,
  380. total: parseFloat(price * this.data.purchasePrice).toFixed(2)
  381. })
  382. if (!this.data.isrealPayMoney) {
  383. this.setData({
  384. realPayMoney: parseFloat(price * this.data.purchasePrice).toFixed(2),
  385. })
  386. }
  387. this.setData({
  388. needpay: parseFloat(this.data.purchasePrice * price - this.data.realPayMoney).toFixed(2)
  389. })
  390. },
  391. setpurchasePrice(e) {
  392. var price = util.PointNum(e.detail.value)
  393. this.setData({
  394. purchasePrice: price,
  395. total: parseFloat(price * this.data.purchaseNumber).toFixed(2)
  396. })
  397. if (!this.data.isrealPayMoney) {
  398. this.setData({
  399. realPayMoney: parseFloat(price * this.data.purchaseNumber).toFixed(2),
  400. })
  401. }
  402. this.setData({
  403. needpay: parseFloat(this.data.purchaseNumber * price - this.data.realPayMoney).toFixed(2)
  404. })
  405. },
  406. setgoodsBarcode(e) {
  407. this.setData({
  408. goodsBarcode: e.detail.value
  409. })
  410. },
  411. setgoodsCode(e) {
  412. this.setData({
  413. goodsCode: e.detail.value
  414. })
  415. },
  416. selectgood(e) {
  417. this.setData({
  418. goodid: e.currentTarget.dataset.id,
  419. goodonlyid: e.currentTarget.dataset.onlyid,
  420. goodname: e.currentTarget.dataset.name,
  421. isgoods: false,
  422. cover: false
  423. })
  424. var ag = this.data.allgood
  425. for (var i in ag) {
  426. if (ag[i].id === e.currentTarget.dataset.id && ag[i].type) {
  427. this.setData({
  428. goodtypename: ag[i].type.name,
  429. goodtypeid: ag[i].type.id,
  430. goodtypeonlyid: ag[i].type.onlyid
  431. })
  432. }
  433. }
  434. },
  435. /**
  436. * 生命周期函数--监听页面加载
  437. */
  438. onLoad: function(options) {
  439. that = this
  440. util.checklogin(
  441. function() {
  442. that.getSet()
  443. that.getAllGood()
  444. that.getSupplierListData()
  445. util.getPayWay(function(e) {
  446. that.setData({
  447. payWayarray: e
  448. })
  449. })
  450. })
  451. var obj = dateTimePicker.dateTimePicker(this.data.startYear, this.data.endYear);
  452. var obj1 = dateTimePicker.dateTimePicker(this.data.startYear, this.data.endYear);
  453. var obj2 = dateTimePicker.dateTimePicker(this.data.startYear, this.data.endYear);
  454. this.setData({
  455. dateTime: obj.dateTime,
  456. dateTimeArray: obj.dateTimeArray,
  457. dateTime1: obj1.dateTime,
  458. dateTimeArray1: obj1.dateTimeArray,
  459. dateTime2: obj2.dateTime,
  460. dateTimeArray2: obj2.dateTimeArray,
  461. })
  462. if (options.editeid) {
  463. this.setData({
  464. editeid: options.editeid
  465. })
  466. this.getDetail(options.editeid)
  467. } else if (options.copyid) {
  468. this.getDetail(options.copyid, 1)
  469. } else {
  470. }
  471. var ui = wx.getStorageSync('userinfo')
  472. if (ui) {
  473. this.setData({
  474. createUser: ui.wechatName
  475. })
  476. }
  477. },
  478. del() {
  479. wx.showModal({
  480. title: '确认',
  481. content: '是否确定删除该批次',
  482. success(res) {
  483. if (res.confirm) {
  484. var data =
  485. util.query("goodsbatch/wxapi/deletebatch", {
  486. ids: [{
  487. id: that.data.editeid
  488. }]
  489. }, function(res) {
  490. if (res.code == 10000) {
  491. util.showToast('删除成功')
  492. setTimeout(function() {
  493. wx.navigateBack({
  494. delta: 1
  495. })
  496. }, 2000)
  497. } else {
  498. util.showToast(res.message)
  499. }
  500. }, "POST")
  501. } else if (res.cancel) {
  502. }
  503. }
  504. })
  505. },
  506. getDetail(id, iscopy) {
  507. util.query('goodsbatch/wxapi/findbyid', {
  508. id: id
  509. }, function(res) {
  510. if (res.code === 10000) {
  511. var da = res.data
  512. that.setData({
  513. goodname: da.goods.name,
  514. goodid: da.goods.id,
  515. goodonlyid: da.goods.onlyID,
  516. goodtypename: da.goods.goodsCategory ? da.goods.goodsCategory.name : '',
  517. goodtypeid: da.goods.goodsCategory ? da.goods.goodsCategory.id : 0,
  518. goodtypeonlyid: da.goods.goodsCategory ? da.goods.goodsCategory.onlyID : 0,
  519. goodsCode: da.goodsCode,
  520. goodsBarcode: da.goodsBarcode,
  521. purchasePrice: da.purchasePrice,
  522. purchaseNumber: da.purchaseNumber,
  523. payWay: da.payWay,
  524. supplierid: da.supplier ? da.supplier.id : 0,
  525. supplieronlyid: da.supplier ? da.supplier.onlyID : 0,
  526. suppliername: da.supplier ? da.supplier.name : '请选择',
  527. prices1: da.prices1,
  528. submitDate: da.submitDate ? da.submitDate : '请选择',
  529. productionDate: da.productionDate ? da.productionDate : '请选择',
  530. begoodTime: da.begoodTime ? da.begoodTime : '请选择',
  531. images: da.image ? [da.image] : [],
  532. imagessize: da.image ? 1 : 0,
  533. factory: da.factory,
  534. explains: da.explains,
  535. needpay: parseFloat(da.purchasePrice * da.purchaseNumber - da.realPayMoney).toFixed(2), //da.needpay ? da.needpay : 0,
  536. realPayMoney: da.realPayMoney ? da.realPayMoney : 0,
  537. sellPrice: da.sellPrice,
  538. prices1: da.prices1,
  539. prices2: da.prices2,
  540. prices3: da.prices3,
  541. prices4: da.prices4,
  542. prices5: da.prices5,
  543. olddata: da,
  544. total: parseFloat(da.purchasePrice * da.purchaseNumber).toFixed(2),
  545. // createUser: da.userName
  546. })
  547. if (res.data.submitDate) {
  548. var date = res.data.submitDate.split(' ')[0].split('-')
  549. var time = res.data.submitDate.split(' ')[1].split(':')
  550. that.dateUpdate(0, parseInt(date[0]) - that.data.startYear)
  551. that.dateUpdate(1, parseInt(date[1]) - 1)
  552. that.dateUpdate(2, parseInt(date[2]) - 1)
  553. that.dateUpdate(3, parseInt(time[0]))
  554. that.dateUpdate(4, parseInt(time[1]))
  555. that.dateUpdate(5, parseInt(time[2]))
  556. }
  557. if (res.data.productionDate) {
  558. date = res.data.productionDate.split(' ')[0].split('-')
  559. time = res.data.productionDate.split(' ')[1].split(':')
  560. that.dateUpdate1(0, parseInt(date[0]) - that.data.startYear)
  561. that.dateUpdate1(1, parseInt(date[1]) - 1)
  562. that.dateUpdate1(2, parseInt(date[2]) - 1)
  563. that.dateUpdate1(3, parseInt(time[0]))
  564. that.dateUpdate1(4, parseInt(time[1]))
  565. that.dateUpdate1(5, parseInt(time[2]))
  566. }
  567. if (res.data.begoodTime) {
  568. date = res.data.begoodTime.split(' ')[0].split('-')
  569. time = res.data.begoodTime.split(' ')[1].split(':')
  570. that.dateUpdate2(0, parseInt(date[0]) - that.data.startYear)
  571. that.dateUpdate2(1, parseInt(date[1]) - 1)
  572. that.dateUpdate2(2, parseInt(date[2]) - 1)
  573. that.dateUpdate2(3, parseInt(time[0]))
  574. that.dateUpdate2(4, parseInt(time[1]))
  575. that.dateUpdate2(5, parseInt(time[2]))
  576. }
  577. if (!iscopy) {
  578. that.setData({
  579. id: da.id,
  580. onlyid: da.onlyID
  581. })
  582. }
  583. } else {
  584. util.showToast('未发现该批次')
  585. }
  586. })
  587. },
  588. setname(e) {
  589. this.setData({
  590. goodname: e.detail.value
  591. })
  592. this.setData({
  593. goodid: 0
  594. })
  595. if (e.detail.value) {
  596. this.findname(e.detail.value)
  597. } else {
  598. this.setData({
  599. isgoods: false
  600. })
  601. }
  602. },
  603. findname(name) {
  604. var da = this.data.allgood
  605. var j = 0
  606. for (var i in da) {
  607. da[i].s = false
  608. if (da[i].name && da[i].name.indexOf(name) > -1) {
  609. da[i].s = true
  610. j++
  611. }
  612. }
  613. this.setData({
  614. allgood: da
  615. })
  616. if (j > 0) {
  617. this.showgoods()
  618. } else {
  619. this.hidecover()
  620. }
  621. },
  622. showgoods() {
  623. this.showcover()
  624. this.setData({
  625. isgoods: true,
  626. })
  627. },
  628. showcover() {
  629. this.setData({
  630. cover: true
  631. })
  632. },
  633. hidecover() {
  634. this.setData({
  635. cover: false,
  636. isgoods: false,
  637. })
  638. },
  639. getAllGood() {
  640. util.query('goods/wxapi/list', {}, function(res) {
  641. if (res.code === 10000) {
  642. var da = res.data
  643. var allgood = []
  644. for (var i in da) {
  645. var d = {
  646. id: da[i].id,
  647. name: da[i].name,
  648. s: false,
  649. onlyID: da[i].onlyID
  650. }
  651. if (da[i].goodsCategory) {
  652. d.type = {
  653. id: da[i].goodsCategory.id,
  654. name: da[i].goodsCategory.name,
  655. onlyid: da[i].goodsCategory.onlyID
  656. }
  657. }
  658. allgood.push(d)
  659. }
  660. that.setData({
  661. allgood: allgood
  662. })
  663. } else {
  664. util.showToast('查询商品失败')
  665. }
  666. })
  667. },
  668. /**
  669. * 生命周期函数--监听页面初次渲染完成
  670. */
  671. onReady: function() {
  672. },
  673. /**
  674. * 生命周期函数--监听页面显示
  675. */
  676. onShow: function() {
  677. },
  678. /**
  679. * 生命周期函数--监听页面隐藏
  680. */
  681. onHide: function() {
  682. },
  683. /**
  684. * 生命周期函数--监听页面卸载
  685. */
  686. onUnload: function() {
  687. },
  688. /**
  689. * 页面相关事件处理函数--监听用户下拉动作
  690. */
  691. onPullDownRefresh: function() {
  692. },
  693. /**
  694. * 页面上拉触底事件的处理函数
  695. */
  696. onReachBottom: function() {
  697. },
  698. /**
  699. * 用户点击右上角分享
  700. */
  701. onShareAppMessage: function() {
  702. }
  703. })