project-detail.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818
  1. var width = 0
  2. var height = 0
  3. var ctx
  4. var _request = require('../../../utils/request.js')
  5. var _handle = require('../../../utils/handle.js')
  6. var WxParse = require('../../../utils/wxParse/wxParse.js')
  7. var util = require('../../../utils/accounting.min.js')
  8. var fomldsJSON = ''
  9. Page({
  10. posterImage: {},
  11. posterLoading: 0,
  12. canvasLoading: false,
  13. qcodeError: false,
  14. data: {
  15. productId: 0,
  16. indicatorDots: false,
  17. autoplay: false,
  18. interval: 5000,
  19. duration: 1000,
  20. project: {},
  21. showDialog: false,
  22. showCartDialog: false,
  23. animationData: {},
  24. count: 1,
  25. image: {},
  26. bindTel: false,
  27. balance: 0,
  28. posterPopup: false,
  29. posterImage: null,
  30. imgindex: 1,
  31. popup: false,
  32. hour: '00',
  33. min: '00',
  34. second: '00',
  35. timer: '',
  36. leftTime: '0',
  37. // msecond: '00',
  38. clock: '',
  39. todaysend: Date.parse(new Date()) / 1000,
  40. showpay: true,
  41. productSize:'',//产品规格
  42. size_list:0,
  43. color_list:0,
  44. cname:'',
  45. sname:'',
  46. canpay:true,
  47. checkbox:'',
  48. noproduct:false,
  49. check:{}
  50. },
  51. onLoad: function (options) {
  52. this.data.productId = options.id;
  53. this.getBalanceInfo()
  54. },
  55. onShow: function () {
  56. this.getIphoneX()
  57. this.getProjectDetail()
  58. this.check()
  59. },
  60. onHide: function () {
  61. this.getneedshare()
  62. },
  63. dpi: function (val) {
  64. return val
  65. },
  66. onSlideChangeEnd: function(e) {
  67. var that = this;
  68. that.setData({
  69. imgindex: e.detail.current + 1
  70. })
  71. },
  72. check () {
  73. var that = this
  74. var url = 'v1/user/check'
  75. var params = {
  76. }
  77. var success = function (res) {
  78. that.setData({check:res.data})
  79. if (res.data.user_id > 0) {
  80. that.setData({
  81. bindTel: true
  82. })
  83. }
  84. if (res.data.wx_user_id > 0) {
  85. that.getneedshare()
  86. }
  87. }
  88. _request.$get(url, params, success)
  89. },
  90. onShareAppMessage: function (val) {
  91. this.shareInfo()
  92. this.setData({
  93. showpay: true
  94. })
  95. return _request.share({
  96. title: this.data.project.share_content || this.data.project.name,
  97. path: '/pages/start/start?url=pages/projects/project-detail/project-detail&id=' + this.data.productId,
  98. imageUrl: this.data.project.share_img,
  99. sc: 'xcx_product',
  100. ri: this.data.productId,
  101. rp: this.data.productId,
  102. })
  103. },
  104. // imageLoad: function (e) {
  105. // var _width = e.detail.width,
  106. // _height = e.detail.height,
  107. // ratio = _width / _height;
  108. // var viewWidth = 750,
  109. // viewHeight = 750 / ratio;
  110. // var image = this.data.image;
  111. // image[e.target.dataset.index]={
  112. // width:viewWidth,
  113. // height:viewHeight
  114. // }
  115. // this.setData({
  116. // images:image
  117. // })
  118. // },
  119. shareInfo () {
  120. var that = this
  121. var url = "v1/share/info"
  122. var params = {
  123. sc: 'xcx_product',
  124. ri: that.data.productId,
  125. rp: that.data.productId,
  126. to: 'group'
  127. }
  128. var success = function (val) {
  129. console.log(val)
  130. }
  131. _request.$post(url, params, success)
  132. },
  133. detailImg: function (event) {
  134. var src = event.currentTarget.dataset.src;
  135. var imgList = event.currentTarget.dataset.list;
  136. var imgLists = []
  137. for (var i = 0; i < imgList.length; i++) {
  138. imgLists.push(imgList[i].img)
  139. }
  140. wx.previewImage({
  141. current: src,
  142. urls: imgLists
  143. })
  144. },
  145. getProjectDetail () {
  146. var that = this
  147. var url = "v1/product/" + that.data.productId;
  148. var params = {}
  149. var success = function (val) {
  150. var p = val.data.detail
  151. that.setData({
  152. project: val.data,
  153. clock: val.data.seckill_end
  154. });
  155. WxParse.wxParse('parse', 'html', p, that, 10)
  156. if (val.data.seckill_state == 'seckill') {
  157. that.starttime()
  158. }
  159. if(val.data.have_size){
  160. that.getProductSize();
  161. }
  162. }
  163. _request.$get(url, params, success)
  164. },
  165. getProductSize(){
  166. var that = this
  167. var url = "v1/product_size/" + that.data.productId;
  168. var params = {}
  169. var success = function (val) {
  170. let cbox = [];
  171. for(let i in val.data){
  172. if(i != 'product' && val.data[i]) cbox.push(i);
  173. }
  174. console.log('cbox',cbox)
  175. that.setData({
  176. productSize: val.data,
  177. checkbox:cbox
  178. });
  179. }
  180. _request.$get(url, params, success)
  181. },
  182. getProductDetail () {
  183. var that = this;
  184. console.log(that.data.size_list);
  185. console.log(that.data.color_list);
  186. var url = "v1/product_detail/" + that.data.productId + "/" + that.data.size_list + "/" + that.data.color_list;
  187. var params = {}
  188. var success = function (val) {
  189. console.log('val',val)
  190. if(val.data.product){
  191. that.setData({
  192. canpay:true,
  193. project:val.data.product,
  194. productId:val.data.product.id,
  195. noproduct:false
  196. })
  197. that.setData({
  198. canpay:true,
  199. project:val.data.product,
  200. productId:val.data.product.id,
  201. noproduct:false
  202. })
  203. }else{
  204. that.setData({
  205. canpay:false,
  206. noproduct:true
  207. })
  208. }
  209. }
  210. var fail = function(err){
  211. }
  212. _request.$get(url, params, success, fail)
  213. },
  214. add: function () {
  215. if (this.data.count < this.data.project.left_count) {
  216. var count = this.data.count + 1
  217. this.setData({
  218. count: count
  219. })
  220. }
  221. },
  222. mius: function () {
  223. if (this.data.count > 1) {
  224. var count = this.data.count - 1
  225. this.setData({
  226. count: count
  227. })
  228. }
  229. },
  230. changeCount: function (val) {
  231. var count = val.detail.value
  232. if (count <= 0) {
  233. this.setData({
  234. count: 1
  235. })
  236. } else if (count > this.data.project.left_count) {
  237. this.setData({
  238. count: this.data.project.left_count
  239. })
  240. } else {
  241. this.setData({
  242. count: count
  243. })
  244. }
  245. },
  246. // 显示弹框
  247. showModal: function (type) {
  248. var animation = wx.createAnimation({
  249. duration: 200,
  250. timingFunction: "ease-out"
  251. })
  252. this.animation = animation
  253. animation.translateY(500).step()
  254. if(type == 1){
  255. this.setData({
  256. animationData: animation.export(),
  257. showDialog: true
  258. })
  259. }else{
  260. this.setData({
  261. animationData: animation.export(),
  262. showCartDialog: true
  263. })
  264. }
  265. setTimeout(function () {
  266. animation.translateY(0).step()
  267. this.setData({
  268. animationData: animation.export()
  269. })
  270. }.bind(this), 200)
  271. },
  272. // 隐藏弹框
  273. hideModal: function (type = 1) {
  274. var animation = wx.createAnimation({
  275. duration: 200,
  276. timingFunction: "ease-out"
  277. })
  278. this.animation = animation
  279. animation.translateY(500).step()
  280. this.setData({
  281. animationData: animation.export(),
  282. })
  283. setTimeout(function () {
  284. animation.translateY(0).step()
  285. if(type == 1){
  286. this.setData({
  287. animationData: animation.export(),
  288. showDialog: false
  289. })
  290. }else{
  291. this.setData({
  292. animationData: animation.export(),
  293. showCartDialog: false
  294. })
  295. }
  296. }.bind(this), 200)
  297. },
  298. getneedshare () {
  299. var that = this
  300. var url = "v1/product/" + that.data.productId + "/share"
  301. var params = {
  302. }
  303. var success = function (val) {
  304. if (val.data.need_share == 1) {
  305. that.setData({
  306. showpay: false
  307. })
  308. }
  309. }
  310. _request.$get(url, params, success)
  311. },
  312. toPay: function (e) {
  313. _handle.setFormId(e)
  314. if (this.data.bindTel) {
  315. var that = this
  316. that.data.showDialog = !that.data.showDialog
  317. if (that.data.showDialog) {
  318. that.showModal(1)
  319. } else {
  320. that.hideModal(1)
  321. }
  322. } else {
  323. wx.navigateTo({
  324. url: '/packageUser/pages/user/bind/bind'
  325. })
  326. }
  327. },
  328. toCart: function (e) {
  329. _handle.setFormId(e)
  330. if (this.data.bindTel) {
  331. var that = this
  332. that.data.showCartDialog = !that.data.showCartDialog
  333. if (that.data.showCartDialog) {
  334. that.showModal(2)
  335. } else {
  336. that.hideModal(2)
  337. }
  338. } else {
  339. wx.navigateTo({
  340. url: '/packageUser/pages/user/bind/bind'
  341. })
  342. }
  343. },
  344. pay: function (e) {
  345. _handle.setFormId(e)
  346. var that = this
  347. //规格
  348. let cflag = true;
  349. for(let i in that.data.checkbox){
  350. if(that.data[that.data.checkbox[i]] == 0) cflag = false;
  351. }
  352. if(!cflag){
  353. wx.showToast({
  354. title: '请先选择商品规格~',
  355. icon: 'none',
  356. duration: 2000
  357. })
  358. return false;
  359. }
  360. var url = "v1/product/" + that.data.productId + "/order/" + that.data.count
  361. var params = {}
  362. var success = function (res) {
  363. if (res.data.order_id) {
  364. wx.navigateTo({
  365. url: '../../pay/pay?orderId=' + res.data.order_id
  366. })
  367. that.hideModal()
  368. that.setData({
  369. count: 1
  370. })
  371. }
  372. }
  373. if (that.data.count <= that.data.project.left_count) {
  374. _request.$post(url, params, success)
  375. } else {
  376. wx.showToast({
  377. title: '库存不足~',
  378. icon: 'none',
  379. duration: 2000
  380. })
  381. }
  382. },
  383. addCart:function(){
  384. var that = this;
  385. //规格
  386. let cflag = true;
  387. for(let i in that.data.checkbox){
  388. if(that.data[that.data.checkbox[i]] == 0) cflag = false;
  389. }
  390. if(!cflag){
  391. wx.showToast({
  392. title: '请先选择商品规格~',
  393. icon: 'none',
  394. duration: 2000
  395. })
  396. return false;
  397. }
  398. console.log('that.data.productId',that.data.productId)
  399. var url = "v1/cart/" + that.data.productId + "/" + that.data.count
  400. var params = {}
  401. var success = function (res) {
  402. if(res.data.result){
  403. that.hideModal(2);
  404. wx.showToast({
  405. title: '添加成功,请到购物车查看~',
  406. icon: 'none',
  407. duration: 2000
  408. })
  409. }
  410. // if (res.data.order_id) {
  411. // wx.navigateTo({
  412. // url: '../../pay/pay?orderId=' + res.data.order_id
  413. // })
  414. // that.hideModal()
  415. // that.setData({
  416. // count: 1
  417. // })
  418. // }
  419. }
  420. if (that.data.count <= that.data.project.left_count) {
  421. _request.$post(url, params, success)
  422. } else {
  423. wx.showToast({
  424. title: '库存不足~',
  425. icon: 'none',
  426. duration: 2000
  427. })
  428. }
  429. },
  430. getIphoneX () {
  431. var that = this
  432. wx.getSystemInfo({
  433. success: function (res) {
  434. if (res.model.toLowerCase().indexOf('iphone x') > -1) {
  435. that.setData({
  436. value: 34
  437. })
  438. }
  439. }
  440. })
  441. },
  442. getBalanceInfo () {
  443. var that = this
  444. var url = 'v1/user/balance/info'
  445. var params = {
  446. }
  447. var success = function (res) {
  448. var result = res.data.total
  449. that.setData({
  450. balance: result
  451. })
  452. }
  453. _request.$get(url, params, success)
  454. },
  455. projectImageLoading () {
  456. var that = this
  457. wx.getImageInfo({
  458. src: 'https://cfohow.hiwavo.com/xcx/poster6.jpg',
  459. success: function (res) {
  460. that.posterImage.bg = res
  461. that.posterLoading++
  462. if (that.posterLoading === 4) {
  463. that.createCtx()
  464. }
  465. }
  466. })
  467. if (this.data.project.pics.length > 0) {
  468. wx.getImageInfo({
  469. src: this.data.project.pics[0].img,
  470. success: function (res) {
  471. that.posterImage.project = res
  472. that.posterLoading++
  473. if (that.posterLoading === 4) {
  474. that.createCtx()
  475. }
  476. }
  477. })
  478. }
  479. var url = 'v1/poster/' + this.data.productId
  480. var params = {
  481. type: 'project'
  482. }
  483. var success = function (res) {
  484. wx.getImageInfo({
  485. src: res.data.qrcode_url,
  486. success: function (res) {
  487. that.posterImage.qcode = res
  488. that.posterLoading++
  489. if (that.posterLoading === 4) {
  490. that.createCtx()
  491. }
  492. },
  493. fail: function (res) {
  494. var url = 'v1/update/poster/' + this.data.productId
  495. var params = {
  496. type: 'project'
  497. }
  498. var success = function (res) {
  499. wx.getImageInfo({
  500. src: res.data.qrcode_url,
  501. success: function (res) {
  502. that.posterImage.qcode = res
  503. that.posterLoading++
  504. if (that.posterLoading === 4) {
  505. that.createCtx()
  506. }
  507. },
  508. fail: function (res) {
  509. that.qcodeError = true
  510. if (that.data.posterPopup) {
  511. that.setData({
  512. posterPopup: false
  513. })
  514. wx.showToast({
  515. title: '海报生成失败,请稍后重试',
  516. icon: 'none',
  517. duration: 2000
  518. })
  519. wx.hideLoading()
  520. }
  521. }
  522. })
  523. wx.getImageInfo({
  524. src: res.data.wx_head,
  525. success: function (res) {
  526. that.posterImage.head = res
  527. that.posterLoading++
  528. if (that.posterLoading === 4) {
  529. that.createCtx()
  530. }
  531. }
  532. })
  533. }
  534. _request.$put(url, params, success)
  535. // that.qcodeError = true
  536. // if (that.data.posterPopup) {
  537. // that.setData({
  538. // posterPopup: false
  539. // })
  540. // wx.showToast({
  541. // title: '海报生成失败,请稍后重试',
  542. // icon: 'none',
  543. // duration: 2000
  544. // })
  545. // wx.hideLoading()
  546. // }
  547. }
  548. })
  549. wx.getImageInfo({
  550. src: res.data.wx_head,
  551. success: function (res) {
  552. that.posterImage.head = res
  553. that.posterLoading++
  554. if (that.posterLoading === 4) {
  555. that.createCtx()
  556. }
  557. }
  558. })
  559. }
  560. _request.$get(url, params, success)
  561. },
  562. createPoster () {
  563. let that = this;
  564. if(this.data.check && this.data.check.wx_user_id && this.data.check.wx_user_id > 0 && this.data.check.user_id > 0){
  565. that.projectImageLoading()
  566. if (!this.qcodeError) {
  567. if (!this.canvasLoading) {
  568. wx.showLoading({
  569. mask: true,
  570. title: ''
  571. })
  572. }
  573. this.setData({
  574. posterPopup: true
  575. })
  576. } else {
  577. wx.showToast({
  578. title: '海报生成失败,请稍后重试',
  579. icon: 'none',
  580. duration: 2000
  581. })
  582. }
  583. }else{
  584. wx.showToast({
  585. title: '请先完成授权登录',
  586. icon: 'none',
  587. duration: 2000
  588. })
  589. }
  590. },
  591. posterClose () {
  592. this.setData({
  593. posterPopup: false
  594. })
  595. },
  596. createCtx () {
  597. var that = this
  598. ctx = wx.createCanvasContext('myCanvas')
  599. ctx.drawImage(this.posterImage.bg.path, 0, 0, this.dpi(this.posterImage.bg.width), this.dpi(this.posterImage.bg.height))
  600. ctx.drawImage(this.posterImage.qcode.path, this.dpi(501), this.dpi(1140), this.dpi(180), this.dpi(180))
  601. ctx.save()
  602. ctx.translate(this.dpi(44),this.dpi(46))
  603. ctx.save()
  604. ctx.arc(this.dpi(60), this.dpi(59), this.dpi(40), 0, Math.PI * 2, false)
  605. ctx.lineWidth = 1
  606. ctx.strokeStyle = '#d4d4d4'
  607. ctx.stroke()
  608. ctx.clip()
  609. ctx.drawImage(this.posterImage.head.path, this.dpi(21), this.dpi(20), this.dpi(78), this.dpi(78))
  610. ctx.restore()
  611. ctx.save()
  612. ctx.textBaseline = 'middle'
  613. ctx.font = this.dpi(24) + 'px Arial'
  614. ctx.fillStyle = '#eab86a'
  615. ctx.fillText('源处全球源产地的优质产品!', this.dpi(136), this.dpi(59))
  616. ctx.restore()
  617. ctx.drawImage(this.posterImage.project.path, this.dpi(20), this.dpi(140), this.dpi(622), this.dpi(622))
  618. ctx.beginPath()
  619. ctx.moveTo(this.dpi(0), this.dpi(119))
  620. ctx.lineTo(this.dpi(662), this.dpi(119))
  621. ctx.lineWidth = 1
  622. ctx.strokeStyle = '#eab86a'
  623. ctx.stroke()
  624. ctx.closePath()
  625. ctx.save()
  626. ctx.translate(this.dpi(20),this.dpi(784))
  627. ctx.textBaseline = 'middle'
  628. ctx.font = this.dpi(28) + 'px Arial'
  629. ctx.fillStyle = '#bbbbbb'
  630. ctx.fillText('购买单价', this.dpi(46), this.dpi(50))
  631. ctx.fillStyle = '#eab86a'
  632. ctx.setTextAlign('right')
  633. ctx.font = 'bold ' + this.dpi(54) + 'px Arial'
  634. ctx.fillText(util.formatMoney(this.data.project.price / 100, '¥', 2), this.dpi(584), this.dpi(50))
  635. ctx.setTextAlign('left')
  636. ctx.font = this.dpi(32) + 'px Arial'
  637. ctx.fillStyle = '#2b2b2b'
  638. this.textAutoLine(this.data.project.name, this.dpi(30), this.dpi(150), this.dpi(40))
  639. ctx.restore()
  640. ctx.restore()
  641. ctx.draw(true, function callback () {
  642. that.createImage()
  643. })
  644. },
  645. createImage () {
  646. var that = this
  647. wx.canvasToTempFilePath({
  648. destWidth: 750,
  649. destHeight: 1334,
  650. canvasId: 'myCanvas',
  651. fileType: 'jpg',
  652. success: function (res) {
  653. that.setData({
  654. posterImage: res.tempFilePath
  655. })
  656. that.canvasLoading = true
  657. wx.hideLoading()
  658. }
  659. })
  660. },
  661. saveImage () {
  662. var that = this
  663. wx.showLoading({
  664. mask: true,
  665. title: ''
  666. })
  667. wx.saveImageToPhotosAlbum({
  668. filePath: this.data.posterImage,
  669. success (res) {
  670. wx.showToast({
  671. title: '已保存相册',
  672. icon: 'success',
  673. duration: 2000
  674. })
  675. },
  676. fail (res) {
  677. wx.getSetting({
  678. success (res) {
  679. if (!res.authSetting['scope.writePhotosAlbum']) {
  680. that.setData({
  681. popup: true
  682. })
  683. }
  684. }
  685. })
  686. wx.hideLoading()
  687. }
  688. })
  689. },
  690. setting () {
  691. this.setData({
  692. popup: false
  693. })
  694. },
  695. roundRect (x, y, w, h, r, color) {
  696. ctx.beginPath()
  697. ctx.moveTo(x+r, y)
  698. ctx.arcTo(x+w, y, x+w, y+h, r)
  699. ctx.arcTo(x+w, y+h, x, y+h, r)
  700. ctx.arcTo(x, y+h, x, y, r)
  701. ctx.arcTo(x, y, x+w, y, r)
  702. ctx.closePath()
  703. ctx.fillStyle = color
  704. ctx.fill()
  705. },
  706. textAutoLine (str, initX, initY, lineHeight) {
  707. let lineWidth = 0
  708. let textWidth = this.dpi(580)
  709. let lastSubStrIndex= 0
  710. for (let i = 0; i < str.length; i++) {
  711. lineWidth += ctx.measureText(str[i]).width
  712. if (lineWidth > textWidth - initX) {
  713. ctx.fillText(str.substring(lastSubStrIndex, i), initX, initY)
  714. initY += lineHeight
  715. lineWidth = 0
  716. lastSubStrIndex = i
  717. }
  718. if (i === str.length - 1) {
  719. ctx.fillText(str.substring(lastSubStrIndex, i + 1), initX, initY)
  720. }
  721. }
  722. },
  723. stopPageScroll () {
  724. return
  725. },
  726. starttime () {
  727. var that = this
  728. that.setData({
  729. timer: setInterval(function () {
  730. // var date = new Date();
  731. // var now = date.getTime();
  732. // var endDate = new Date("2019-01-03 23:14:53");//设置截止时间
  733. // var end = that.data.clock * 1000;//设置截止时间
  734. // var end = endDate.getTime();
  735. // var leftTime = end - now; //时间差
  736. var t = Date.parse(new Date())
  737. t = t / 1000;
  738. var leftTime = that.data.clock - t
  739. var d, h, m, s, ms;
  740. if (leftTime >= 0) {
  741. // day = parseInt(ctime / 86400)
  742. h = parseInt(leftTime / 3600)
  743. m = parseInt(leftTime / 60 ) - parseInt(leftTime / 3600) * 60
  744. s = parseInt(leftTime) - parseInt(leftTime / 60 ) * 60
  745. // d = Math.floor(leftTime / 1000 / 60 / 60 / 24);
  746. // h = Math.floor(leftTime / 1000 / 60 / 60 % 24);
  747. // m = Math.floor(leftTime / 1000 / 60 % 60);
  748. // s = Math.floor(leftTime / 1000 % 60);
  749. // ms = Math.floor(leftTime % 1000);
  750. // ms = ms < 100 ? "0" + ms : ms
  751. s = s < 10 ? "0" + s : s
  752. m = m < 10 ? "0" + m : m
  753. h = h < 10 ? "0" + h : h
  754. that.setData({
  755. hour: h,
  756. min: m,
  757. second: s,
  758. // msecond: ms,
  759. leftTime: leftTime
  760. })
  761. }
  762. if (leftTime < 0) {
  763. clearInterval(that.data.timer);
  764. that.setData({
  765. leftTime: 0,
  766. hour: '00',
  767. min: '00',
  768. second: '00',
  769. // msecond: '00'
  770. })
  771. }
  772. },100),
  773. });
  774. },
  775. checkSize(event){
  776. var type = event.currentTarget.dataset.type;
  777. var id = event.currentTarget.dataset.id;
  778. var list = event.currentTarget.dataset.list;
  779. var tname = event.currentTarget.dataset.tname;
  780. var that = this;
  781. var tkey = type=='color_list'?'cname':'sname';
  782. var reproduct = this.data.productSize;
  783. // console.log('reproduct',reproduct)
  784. for(var i in reproduct[type]['attr_values']){
  785. // console.log('reproduct[type][i].is_select',reproduct[type]['attr_values'][i].is_select)
  786. reproduct[type]['attr_values'][i].is_select = false;
  787. if(reproduct[type]['attr_values'][i].id == id) reproduct[type]['attr_values'][i].is_select = true;
  788. }
  789. // console.log('reproduct',reproduct)
  790. that.setData({
  791. productSize :reproduct,
  792. [type]:id,
  793. [tkey]:tname
  794. })
  795. // console.log('that.data[type]',that.data[type])
  796. let cflag = true;
  797. for(let i in that.data.checkbox){
  798. if(that.data[that.data.checkbox[i]] == 0) cflag = false;
  799. }
  800. if(cflag){
  801. that.getProductDetail();
  802. }
  803. }
  804. })