buyOnly.js 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594
  1. // buy.js
  2. var app = getApp();
  3. var WxParse = require('../../wxParse/wxParse.js');
  4. var goodsInfor = {
  5. cycle: 10,
  6. minNumber: 100
  7. };
  8. //服务
  9. var goodsService = [
  10. ];
  11. //礼盒
  12. var gixboxService = [
  13. ];
  14. //定制
  15. var dingzhiService = [
  16. ];
  17. //定制
  18. var Style1 = [
  19. ];
  20. //定制
  21. var Style2 = [
  22. ];
  23. //定制
  24. var Style3 = [
  25. ];
  26. //定制
  27. var Style4 = [
  28. ];
  29. //定制
  30. var Style5 = [
  31. ];
  32. //选择颜色
  33. var colorList = [
  34. ];
  35. //规格选择
  36. var ruleList = [
  37. { id: 1, icon: "/images/collect_pre.png", rule: "规格1" },
  38. { id: 2, icon: "/images/collect_pre.png", rule: "规格2" },
  39. { id: 3, icon: "/images/collect_pre.png", rule: "规格3" }
  40. ];
  41. var recommend = "";
  42. let animationShowHeight = 1000;
  43. Page({
  44. /**
  45. * 页面的初始数据
  46. */
  47. data: {
  48. urlHttp: '',
  49. banner: '',
  50. bannerSml: '',
  51. title: '',
  52. shangpin_id: '',
  53. intro: '',
  54. newPrice: '',
  55. oldPrice: '',
  56. allPrice: '',
  57. cycle: '',
  58. brandname: '',
  59. brandlogo: '',
  60. brandBanner: '',
  61. bannerShare:  '',//分享的图片
  62. minNumber: '',
  63. goodsInfor: goodsInfor,
  64. goodsService: goodsService,
  65. gixboxService: gixboxService,
  66. dingzhiService: dingzhiService,
  67. Style1: Style1,
  68. Style2: Style2,
  69. Style3: Style3,
  70. Style4: Style4,
  71. Style5: Style5,
  72. serviceLength: 0,
  73. serviceIcon: 0,
  74. giftboxsize: '',
  75. colorList: colorList,
  76. colorListLength: 0,
  77. style1: 0,
  78. style2: 0,
  79. style3: 0,
  80. style4: 0,
  81. style5: 0,
  82. style1_name: '',
  83. style2_name: '',
  84. style3_name: '',
  85. style4_name: '',
  86. style5_name: '',
  87. colorIconNum: 0,
  88. colorClick: 0, //颜色是否选中
  89. commodity_details: '',
  90. ruleList: ruleList,
  91. recommend: recommend,
  92. ruleListLength: 1,
  93. ruleIconNum: 0,
  94. ruleClick: 0, //规格是否选中
  95. brandid: '',
  96. brandtitle: '',
  97. cartNum: 0,
  98. num: 1, //起订量
  99. limitNum: 1,//装起订量
  100. isMinus: false,//初始不可减
  101. totalPrice: 0, // 总价,初始为0
  102. selectColor: "",
  103. selectBox: "",
  104. selectRule: "",
  105. com_id: "",
  106. recommend: "",
  107. collectState: false,
  108. boxClick: "-",//礼盒选中状态
  109. //立即购买中的规格,当前选中状态
  110. ruleClick1: "-",
  111. ruleClick2: "-",
  112. ruleClick3: "-",
  113. ruleClick4: "-",
  114. ruleClick5: "-",
  115. dingZhiClick: "-",//定制
  116. //规格回显值
  117. rule1: "",
  118. rule2: "",
  119. rule3: "",
  120. rule4: "",
  121. rule5: "",
  122. imagewidth: 0,//缩放后的宽
  123. imageheight: 0,//缩放后的高
  124. imageheight1: 0,
  125. state: '',//滚动条状态(有 auto/无 hidden)
  126. carts: [],
  127. hiddenmodal: true, //弹窗
  128. modalCont: '',
  129. stateId: 0,//判断是点击的加入购物车 - 0 / 立即购买 - 1
  130. maxHeight: 0,
  131. imgList: [],//banner数组
  132. serviceIsShow: false,
  133. isShow: false,
  134. chooseFlag: 0,
  135. chooseResult: 0,
  136. animationData: {},
  137. animationDataBuy: {},
  138. animationDataSer: {},
  139. animation: {},
  140. styleLen: 0,
  141. soldOutShow : false ,//商品下架提示信息
  142. com_id : '3419',//正式商品地址
  143. //com_id: '3294',//测试商品地址
  144. user_id : '',
  145. user_allow_num : 0 //该商品对于该用户的限购数量
  146. },
  147. onLoad: function (options) {
  148. var that = this;
  149. var host = getApp().globalData.servsers;
  150. var un_id = getApp().globalData.un_id;
  151. that.setData({
  152. user_id: un_id
  153. })
  154. var serviceLength = goodsService.length;
  155. var iconNum = 0;
  156. for (var i = 0; i < serviceLength; i++) {
  157. if (goodsService[i].icon != '') {
  158. iconNum++;
  159. }
  160. }
  161. var colorListLength = colorList.length;
  162. var colorIconNum = 0;
  163. for (var i = 0; i < colorListLength; i++) {
  164. if (colorList[i].icon != '') {
  165. colorIconNum++;
  166. }
  167. }
  168. var ruleListLength = colorList.length;
  169. var ruleIconNum = 0;
  170. for (var i = 0; i < ruleListLength; i++) {
  171. if (ruleList[i].icon != '') {
  172. ruleIconNum++;
  173. }
  174. }
  175. that.setData({
  176. urlHttp: host,
  177. com_id: that.data.com_id,
  178. "serviceLength": serviceLength,
  179. "serviceIcon": iconNum,
  180. "num": goodsInfor.minNumber,
  181. "limitNum": goodsInfor.minNumber,
  182. "colorListLength": colorListLength,
  183. "colorIconNum": colorIconNum,
  184. "ruleListLength": ruleListLength,
  185. "ruleIconNum": ruleIconNum
  186. })
  187. //商品列表
  188. that = this;
  189. //检测商品是否下架
  190. wx.request({
  191. url: host + "commodityapi/commoditview",
  192. data: {
  193. com_id: that.data.com_id
  194. },
  195. method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
  196. header: {
  197. 'Accept': 'application/json'
  198. },
  199. success: function (res) {
  200. console.log(res.data);
  201. //有此商品
  202. if (res.data.total > 0){
  203. if (res.data.commodity.commodity_flag == '1'){//此商品为下架商品
  204. that.setData({
  205. soldOutShow : true
  206. })
  207. }else{
  208. //获取该用户下的该商品限购数量
  209. wx.request({
  210. url: host + "userapi/user_fake_split_view",
  211. data: {
  212. user_id: that.data.user_id
  213. },
  214. method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
  215. header: {
  216. 'Accept': 'application/json'
  217. },
  218. success: function (res) {
  219. console.log(res.data.rows[0].user_num);
  220. that.setData({
  221. user_allow_num: res.data.rows[0].user_num
  222. })
  223. }
  224. })
  225. }
  226. }
  227. var article1 = res.data.commodity.commodity_details;
  228. WxParse.wxParse('article1', 'html', res.data.commodity.commodity_details, that, 5)
  229. var acceptance = res.data.commodity.commodity_acceptance
  230. wx.request({
  231. url: host + "/brandapi/findAllforid",
  232. data: {
  233. id: res.data.commodity.commodity_brand
  234. },
  235. method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
  236. header: {
  237. 'Accept': 'application/json'
  238. },
  239. success: function (res) {
  240. that.setData({
  241. brandid: res.data.rows[0].id,
  242. brandtitle: res.data.rows[0].brand_des,
  243. brandname: res.data.rows[0].brand_name,
  244. brandlogo: res.data.rows[0].brand_logo2,
  245. brandBanner: res.data.rows[0].brand_logo1
  246. });
  247. if (res == null || res.data == null) {
  248. console.error('网络请求失败');
  249. return;
  250. }
  251. }
  252. });
  253. if (acceptance != null && acceptance != '') {
  254. wx.request({
  255. url: host + "acceptanceapi/findBuy",
  256. data: {
  257. id: acceptance
  258. },
  259. method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
  260. header: {
  261. 'Accept': 'application/json'
  262. },
  263. success: function (res) {
  264. that.setData({
  265. goodsService: res.data.rows
  266. });
  267. if (res == null || res.data == null) {
  268. console.error('网络请求失败');
  269. return;
  270. }
  271. }
  272. });
  273. }
  274. var giftbox = res.data.commodity.commodity_giftbox
  275. if (giftbox != null && giftbox != '') {
  276. wx.request({
  277. url: host + "giftboxapi/findBuy",
  278. data: {
  279. id: giftbox
  280. },
  281. method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
  282. header: {
  283. 'Accept': 'application/json'
  284. },
  285. success: function (res) {
  286. that.setData({
  287. giftboxsize: res.data.total,
  288. gixboxService: res.data.rows
  289. });
  290. if (res == null || res.data == null) {
  291. console.error('网络请求失败');
  292. return;
  293. }
  294. }
  295. });
  296. }
  297. var process = res.data.commodity.commodity_process
  298. if (process != null && process != '') {
  299. wx.request({
  300. url: host + "processapi/findBuy",
  301. data: {
  302. id: process
  303. },
  304. method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
  305. header: {
  306. 'Accept': 'application/json'
  307. },
  308. success: function (res) {
  309. that.setData({
  310. iconNum: res.data.total,
  311. dingzhiService: res.data.rows
  312. });
  313. if (res == null || res.data == null) {
  314. console.error('网络请求失败');
  315. return;
  316. }
  317. }
  318. });
  319. }
  320. var style1 = res.data.commodity.style1
  321. if (style1 != null && style1 != '') {
  322. wx.request({
  323. url: host + "datasheetapi/findAllforid",
  324. data: {
  325. id: res.data.commodity.style1
  326. },
  327. method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
  328. header: {
  329. 'Accept': 'application/json'
  330. },
  331. success: function (res) {
  332. that.setData({
  333. style1_name: res.data.rows[0].datasheet_com_name,
  334. style1: res.data.total,
  335. Style1: res.data.rows
  336. });
  337. if (res == null || res.data == null) {
  338. console.error('网络请求失败');
  339. return;
  340. }
  341. }
  342. });
  343. }
  344. var style2 = res.data.commodity.style2
  345. if (style2 != null && style2 != '') {
  346. wx.request({
  347. url: host + "datasheetapi/findAllforid",
  348. data: {
  349. id: res.data.commodity.style2
  350. },
  351. method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
  352. header: {
  353. 'Accept': 'application/json'
  354. },
  355. success: function (res) {
  356. that.setData({
  357. style2_name: res.data.rows[0].datasheet_com_name,
  358. style2: res.data.total,
  359. Style2: res.data.rows
  360. });
  361. if (res == null || res.data == null) {
  362. console.error('网络请求失败');
  363. return;
  364. }
  365. }
  366. });
  367. }
  368. var style3 = res.data.commodity.style3
  369. if (style3 != null && style3 != '') {
  370. wx.request({
  371. url: host + "datasheetapi/findAllforid",
  372. data: {
  373. id: res.data.commodity.style3
  374. },
  375. method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
  376. header: {
  377. 'Accept': 'application/json'
  378. },
  379. success: function (res) {
  380. that.setData({
  381. style3_name: res.data.rows[0].datasheet_com_name,
  382. style3: res.data.total,
  383. Style3: res.data.rows
  384. });
  385. if (res == null || res.data == null) {
  386. console.error('网络请求失败');
  387. return;
  388. }
  389. }
  390. });
  391. }
  392. var style4 = res.data.commodity.style4
  393. if (style4 != null && style4 != '') {
  394. wx.request({
  395. url: host + "datasheetapi/findAllforid",
  396. data: {
  397. id: res.data.commodity.style4
  398. },
  399. method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
  400. header: {
  401. 'Accept': 'application/json'
  402. },
  403. success: function (res) {
  404. that.setData({
  405. style4_name: res.data.rows[0].datasheet_com_name,
  406. style4: res.data.total,
  407. Style4: res.data.rows
  408. });
  409. if (res == null || res.data == null) {
  410. console.error('网络请求失败');
  411. return;
  412. }
  413. }
  414. });
  415. }
  416. var style5 = res.data.commodity.style5
  417. if (style5 != null && style5 != '') {
  418. wx.request({
  419. url: host + "datasheetapi/findAllforid",
  420. data: {
  421. id: res.data.commodity.style5
  422. },
  423. method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
  424. header: {
  425. 'Accept': 'application/json'
  426. },
  427. success: function (res) {
  428. that.setData({
  429. style5_name: res.data.rows[0].datasheet_com_name,
  430. style5: res.data.total,
  431. Style5: res.data.rows
  432. });
  433. if (res == null || res.data == null) {
  434. console.error('网络请求失败');
  435. return;
  436. }
  437. }
  438. });
  439. }
  440. that.setData({
  441. tuijian: res.data.commodity,
  442. serviceLength: res.data.total,
  443. banner: res.data.images,
  444. bannerShare: res.data.images[0],
  445. bannerSml: host + 'images/' + res.data.images[0],
  446. title: res.data.commodity.commodity_name,
  447. shangpin_id: res.data.commodity.id,
  448. intro: res.data.commodity.commodity_des,
  449. newPrice: res.data.commodity.commodity_sale,
  450. allPrice: res.data.commodity.commodity_sale,
  451. oldPrice: res.data.commodity.commodity_cost,
  452. cycle: res.data.commodity.commodity_cyc,
  453. minNumber: res.data.commodity.commodity_num,
  454. num: res.data.commodity.commodity_num,
  455. recommend: res.data.commodity.commodity_recommend,
  456. });
  457. var imgList = [];
  458. for (var i = 0; i < that.data.banner.length; i++) {
  459. imgList[i] = host + 'images/' + that.data.banner[i];
  460. }
  461. that.setData({
  462. imgList: imgList
  463. })
  464. if (res == null || res.data == null) {
  465. console.error('网络请求失败');
  466. return;
  467. }
  468. wx.setNavigationBarTitle({
  469. title: res.data.commodity.commodity_name
  470. })
  471. }
  472. });
  473. wx.request({
  474. url: host + "collectionapi/findAllforxcx",
  475. data: {
  476. user_id: un_id,
  477. collection_clas: 2,
  478. collection_name: that.data.com_id,
  479. },
  480. method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
  481. header: {
  482. 'Accept': 'application/json'
  483. },
  484. success: function (res) {
  485. if (res.data.total != 0) {
  486. that.setData({
  487. collectState: true
  488. })
  489. }
  490. if (res == null || res.data == null) {
  491. console.error('网络请求失败');
  492. return;
  493. }
  494. }
  495. })
  496. wx.getSystemInfo({
  497. success: function (res) {
  498. animationShowHeight = res.windowHeight;
  499. }
  500. })
  501. // 显示遮罩层
  502. var animation = wx.createAnimation({
  503. duration: 200,
  504. timingFunction: 'linear',
  505. })
  506. this.animation = animation
  507. animation.bottom(-animationShowHeight).step()
  508. this.setData({
  509. animationDataBuy: animation.export()
  510. })
  511. setTimeout(function () {
  512. animation.bottom(-animationShowHeight).step()
  513. this.setData({
  514. animationDataBuy: animation.export()
  515. })
  516. }.bind(this), 200)
  517. },
  518. onShow: function () {
  519. var that = this;
  520. var host = getApp().globalData.servsers;
  521. var un_id = getApp().globalData.un_id;
  522. that.setData({
  523. user_id: un_id
  524. })
  525. //获取该用户下的该商品限购数量
  526. wx.request({
  527. url: host + "userapi/user_fake_split_view",
  528. data: {
  529. user_id: that.data.user_id
  530. },
  531. method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
  532. header: {
  533. 'Accept': 'application/json'
  534. },
  535. success: function (res) {
  536. that.setData({
  537. user_allow_num: res.data.rows[0].user_num
  538. })
  539. }
  540. })
  541. },
  542. //手动填写数量
  543. writeNum: function (e) {
  544. var that = this;
  545. var val = e.detail.value;
  546. var minnum = that.data.num;
  547. var user_allow_num = that.data.user_allow_num;
  548. if (parseInt(val) > parseInt(user_allow_num)){
  549. that.setData({
  550. hiddenmodal: false,
  551. modalCont: '选择数量已达上限'
  552. })
  553. setTimeout(function () {
  554. that.setData({
  555. hiddenmodal: true
  556. })
  557. }, 1000)
  558. if (parseInt(val) > parseInt(minnum)){
  559. that.setData({
  560. minNumber: user_allow_num,
  561. isMinus: true
  562. })
  563. }else{
  564. that.setData({
  565. minNumber: user_allow_num,
  566. isMinus: false
  567. })
  568. }
  569. }else{
  570. if (parseInt(val) > parseInt(minnum)) {
  571. that.setData({
  572. minNumber: val,
  573. isMinus: true
  574. })
  575. } else {
  576. that.setData({
  577. minNumber: minnum,
  578. isMinus: false
  579. })
  580. }
  581. }
  582. },
  583. //立即购买下的选择礼盒
  584. boxSelect: function (options) {
  585. var that = this
  586. var id = options.currentTarget.dataset.id;
  587. var boxPrice = that.data.gixboxService[id].box_price;
  588. that.data.allPrice = that.data.tuijian.commodity_sale;
  589. if (boxPrice == '' || boxPrice == null || boxPrice == undefined) {
  590. boxPrice = 0;
  591. }
  592. var newPrice = parseFloat(that.data.allPrice) + parseFloat(boxPrice); //加上礼盒的价格
  593. if (that.data.boxClick == id) {//变为取消状态
  594. that.setData({
  595. boxClick: '-',
  596. allPrice: that.data.allPrice, //商品原价
  597. selectBox: '',
  598. })
  599. if (that.data.styleLen == 0) {
  600. that.setData({
  601. chooseResult: 0
  602. })
  603. }
  604. } else {
  605. that.setData({
  606. chooseResult: 1,
  607. boxClick: id,
  608. allPrice: newPrice, //加上礼盒的价格
  609. selectBox: that.data.gixboxService[id].giftbox_name,
  610. })
  611. }
  612. },
  613. //立即购买下的规格选择
  614. ruleSelect: function (options) {
  615. var that = this
  616. var id = options.currentTarget.dataset.id;
  617. var ruleNum = options.currentTarget.dataset.rule;//当前规格1-5
  618. var styleLen = that.data.styleLen;
  619. if (ruleNum == 1) {
  620. if (that.data.ruleClick1 == id) {//当前为选中状态,变为取消状态
  621. that.setData({
  622. ruleClick1: '-',
  623. rule1: '',
  624. styleLen: styleLen--
  625. })
  626. } else {
  627. that.setData({
  628. ruleClick1: id,
  629. rule1: that.data.Style1[id].datasheet_name,
  630. styleLen: styleLen++
  631. })
  632. }
  633. } else if (ruleNum == 2) {
  634. if (that.data.ruleClick2 == id) {
  635. that.setData({
  636. ruleClick2: '-',
  637. rule2: '',
  638. styleLen: styleLen--
  639. })
  640. } else {
  641. that.setData({
  642. ruleClick2: id,
  643. rule2: that.data.Style2[id].datasheet_name,
  644. styleLen: styleLen++
  645. })
  646. }
  647. } else if (ruleNum3 == 1) {
  648. if (that.data.ruleClick3 == id) {
  649. that.setData({
  650. ruleClick3: '-',
  651. rule3: '',
  652. styleLen: styleLen--
  653. })
  654. } else {
  655. that.setData({
  656. ruleClick3: id,
  657. rule3: that.data.Style3[id].datasheet_name,
  658. styleLen: styleLen++
  659. })
  660. }
  661. } else if (ruleNum == 4) {
  662. if (that.data.ruleClick4 == id) {
  663. that.setData({
  664. ruleClick4: '-',
  665. rule4: '',
  666. styleLen: styleLen--
  667. })
  668. } else {
  669. that.setData({
  670. ruleClick4: id,
  671. rule4: that.data.Style4[id].datasheet_name,
  672. styleLen: styleLen++
  673. })
  674. }
  675. } else {
  676. if (that.data.ruleClick5 == id) {
  677. that.setData({
  678. ruleClick5: '-',
  679. rule5: '',
  680. styleLen: styleLen--
  681. })
  682. } else {
  683. that.setData({
  684. ruleClick5: id,
  685. rule5: that.data.Style5[id].datasheet_name,
  686. styleLen: styleLen++
  687. })
  688. }
  689. }
  690. if (that.data.styleLen == 0) {
  691. that.setData({
  692. chooseResult: 0
  693. })
  694. } else {
  695. that.setData({
  696. chooseResult: 1
  697. })
  698. }
  699. },
  700. //立即购买下的定制
  701. dingZhiSelect: function (options) {
  702. var that = this
  703. var id = options.currentTarget.dataset.id;
  704. if (that.data.dingZhiClick == id) {//变为取消状态
  705. that.setData({
  706. dingZhiClick: '-',
  707. selectDingZhi: ''
  708. })
  709. } else {
  710. that.setData({
  711. chooseResult: 1,
  712. dingZhiClick: id,
  713. selectDingZhi: this.data.dingzhiService[id].process_name
  714. })
  715. }
  716. //判断当前是否有选择的规格
  717. if (that.data.styleLen == 0) {
  718. that.setData({
  719. chooseResult: 0
  720. })
  721. } else {
  722. that.setData({
  723. chooseResult: 1
  724. })
  725. }
  726. },
  727. //绑定加数量事件
  728. addCount(e) {
  729. var that = this;
  730. let num = this.data.minNumber;
  731. var user_allow_num = that.data.user_allow_num;
  732. if (num == user_allow_num){
  733. that.setData({
  734. hiddenmodal: false,
  735. modalCont: '选择数量已达上限'
  736. })
  737. setTimeout(function () {
  738. that.setData({
  739. hiddenmodal: true
  740. })
  741. }, 1000)
  742. return false;
  743. }else{
  744. num++;
  745. this.setData({
  746. "minNumber": num,
  747. "isMinus": true
  748. })
  749. }
  750. },
  751. //绑定减数量事件
  752. minusCount(e) {
  753. let num = this.data.minNumber;
  754. let minnum = this.data.num;
  755. if (num <= minnum) {
  756. return false;
  757. }
  758. num--;
  759. if (num == minnum) {
  760. this.setData({
  761. "isMinus": false
  762. })
  763. }
  764. this.setData({
  765. "minNumber": num
  766. })
  767. },
  768. //加入购物车
  769. addCart: function (e) {
  770. var that = this;
  771. var scrollTop = that.data.scrollTop;
  772. //判断商品是否已下架,若下架则不可点击
  773. var soldOutShow = that.data.soldOutShow;
  774. if (soldOutShow == true){
  775. return false;
  776. }
  777. that.setData({
  778. chooseFlag: 0,//判断进入购买的入口【底部footer】
  779. stateId: 0
  780. });
  781. wx.getSystemInfo({
  782. success: function (res) {
  783. animationShowHeight = res.windowHeight;
  784. }
  785. })
  786. // 显示遮罩层
  787. var animation = wx.createAnimation({
  788. duration: 400,
  789. timingFunction: 'linear',
  790. })
  791. this.animation = animation
  792. animation.opacity(0).step()
  793. this.setData({
  794. isShow: true,
  795. windBgShow: animation.export()
  796. })
  797. setTimeout(function () {
  798. animation.opacity(1).step()
  799. this.setData({
  800. windBgShow: animation.export()
  801. })
  802. }.bind(this), 200)
  803. //内容
  804. animation.bottom(-animationShowHeight).step()
  805. this.setData({
  806. animationDataBuy: animation.export()
  807. })
  808. setTimeout(function () {
  809. animation.bottom(0).step()
  810. this.setData({
  811. animationDataBuy: animation.export()
  812. })
  813. }.bind(this), 200)
  814. },
  815. //立即购买
  816. buyCart: function (e) {
  817. var that = this;
  818. var scrollTop = that.data.scrollTop;
  819. //判断商品是否已下架,若下架则不可点击
  820. var soldOutShow = that.data.soldOutShow;
  821. if (soldOutShow == true) {
  822. return false;
  823. }
  824. this.setData({
  825. chooseFlag: 0,//判断进入购买的入口【底部footer】
  826. stateId: 1
  827. })
  828. wx.getSystemInfo({
  829. success: function (res) {
  830. animationShowHeight = res.windowHeight;
  831. }
  832. })
  833. var animation = wx.createAnimation({
  834. duration: 400,
  835. timingFunction: 'linear',
  836. })
  837. this.animation = animation
  838. animation.opacity(0).step()
  839. this.setData({
  840. isShow: true,
  841. windBgShow: animation.export()
  842. })
  843. setTimeout(function () {
  844. animation.opacity(1).step()
  845. this.setData({
  846. windBgShow: animation.export()
  847. })
  848. }.bind(this), 200)
  849. // 显示遮罩层
  850. animation.bottom(-animationShowHeight).step()
  851. this.setData({
  852. animationDataBuy: animation.export()
  853. })
  854. setTimeout(function () {
  855. animation.bottom(0).step()
  856. this.setData({
  857. animationDataBuy: animation.export()
  858. })
  859. }.bind(this), 200)
  860. },
  861. //跳转到购物车
  862. linkCart: function (e) {
  863. wx.redirectTo({
  864. url: '/pages/carInsert/carInsert'
  865. })
  866. },
  867. //收藏
  868. collect: function (e) {
  869. var dataState = e.currentTarget.dataset.state;
  870. var host = getApp().globalData.servsers;
  871. var un_id = getApp().globalData.un_id;
  872. var that = this
  873. if (!dataState) {
  874. //后台增加收藏用户收藏数据
  875. wx.request({
  876. url: host + "collectionapi/insertcollection",
  877. data: {
  878. user_id: un_id,
  879. collection_clas: 2,
  880. collection_name: that.data.com_id,
  881. },
  882. method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
  883. header: {
  884. 'Accept': 'application/json'
  885. },
  886. success: function (res) {
  887. if (res == null || res.data == null) {
  888. console.error('网络请求失败');
  889. return;
  890. }
  891. }
  892. })
  893. this.setData({
  894. collectState: true
  895. })
  896. } else {
  897. wx.request({
  898. url: host + "collectionapi / deleteforxcx",
  899. data: {
  900. user_id: un_id,
  901. collection_clas: 2,
  902. collection_name: that.data.com_id,
  903. },
  904. method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
  905. header: {
  906. 'Accept': 'application/json'
  907. },
  908. success: function (res) {
  909. if (res == null || res.data == null) {
  910. console.error('网络请求失败');
  911. return;
  912. }
  913. }
  914. })
  915. this.setData({
  916. collectState: false
  917. })
  918. }
  919. },
  920. //立即购买-去付款
  921. tz: function (e) {
  922. var that = this;
  923. var id = e.currentTarget.dataset.id;
  924. let carts = this.data.carts;
  925. var shangpin_id = this.data.shangpin_id;
  926. var name = this.data.title;
  927. var logo = this.data.bannerSml;
  928. var cost = this.data.newPrice;
  929. var cyc = this.data.cycle;
  930. var number = this.data.minNumber;
  931. var limitNum = this.data.num;//起订量
  932. var acceptance = this.data.title;
  933. var region = this.data.title;
  934. var specifications = this.data.title;
  935. var host = getApp().globalData.servsers;
  936. var un_id = getApp().globalData.un_id;
  937. //规格 : 名称 当前选中的index 当前选中的对应数据Id
  938. var style1 = this.data.Style1;
  939. if (style1 == undefined || style1 == '') {
  940. var styleName1 = '';
  941. var styleId1 = '';
  942. } else {
  943. var styleName1 = this.data.style1_name;
  944. var styleIndex1 = this.data.ruleClick1;
  945. if (styleIndex1 == '-') {
  946. that.setData({
  947. hiddenmodal: false,
  948. modalCont: '请选择' + styleName1
  949. })
  950. setTimeout(function () {
  951. that.setData({
  952. hiddenmodal: true
  953. })
  954. }, 1000)
  955. return false;
  956. } else {
  957. var styleId1 = this.data.Style1[styleIndex1].id;
  958. var styleName1 = this.data.Style1[styleIndex1].datasheet_name;
  959. }
  960. }
  961. var style2 = this.data.Style2;
  962. if (style2 == undefined || style2 == '') {
  963. var styleName2 = '';
  964. var styleId2 = '';
  965. } else {
  966. var styleName2 = this.data.style2_name;
  967. var styleIndex2 = this.data.ruleClick2;
  968. if (styleIndex2 == '-') {
  969. that.setData({
  970. hiddenmodal: false,
  971. modalCont: '请选择' + styleName2
  972. })
  973. setTimeout(function () {
  974. that.setData({
  975. hiddenmodal: true
  976. })
  977. }, 1000)
  978. return false;
  979. } else {
  980. var styleId2 = this.data.Style2[styleIndex2].id;
  981. var styleName2 = this.data.Style2[styleIndex2].datasheet_name;
  982. }
  983. }
  984. var style3 = this.data.Style3;
  985. if (style3 == undefined || style3 == '') {
  986. var styleName3 = '';
  987. var styleId3 = '';
  988. } else {
  989. var styleName3 = this.data.style3_name;
  990. var styleIndex3 = this.data.ruleClick3;
  991. if (styleIndex3 == '-') {
  992. that.setData({
  993. hiddenmodal: false,
  994. modalCont: '请选择' + styleName3
  995. })
  996. setTimeout(function () {
  997. that.setData({
  998. hiddenmodal: true
  999. })
  1000. }, 1000)
  1001. return false;
  1002. } else {
  1003. var styleId3 = this.data.Style3[styleIndex3].id;
  1004. var styleName3 = this.data.Style3[styleIndex3].datasheet_name;
  1005. }
  1006. }
  1007. var style4 = this.data.Style4;
  1008. if (style4 == undefined || style4 == '') {
  1009. var styleName4 = '';
  1010. var styleId4 = '';
  1011. } else {
  1012. var styleName4 = this.data.style4_name;
  1013. var styleIndex4 = this.data.ruleClick4;
  1014. if (styleIndex4 == '-') {
  1015. that.setData({
  1016. hiddenmodal: false,
  1017. modalCont: '请选择' + styleName4
  1018. })
  1019. setTimeout(function () {
  1020. that.setData({
  1021. hiddenmodal: true
  1022. })
  1023. }, 1000)
  1024. return false;
  1025. } else {
  1026. var styleId4 = this.data.Style4[styleIndex4].id;
  1027. var styleName4 = this.data.Style1[styleIndex4].datasheet_name;
  1028. }
  1029. }
  1030. var style5 = this.data.Style5;
  1031. if (style5 == undefined || style5 == '') {
  1032. var styleName5 = '';
  1033. var styleId5 = '';
  1034. } else {
  1035. var styleName5 = this.data.style5_name;
  1036. var styleIndex5 = this.data.ruleClick5;
  1037. if (styleIndex5 == '-') {
  1038. that.setData({
  1039. hiddenmodal: false,
  1040. modalCont: '请选择' + styleName5
  1041. })
  1042. setTimeout(function () {
  1043. that.setData({
  1044. hiddenmodal: true
  1045. })
  1046. }, 1000)
  1047. return false;
  1048. } else {
  1049. var styleId5 = this.data.Style5[styleIndex5].id;
  1050. var styleName5 = this.data.Style5[styleIndex5].datasheet_name;
  1051. }
  1052. }
  1053. //礼盒 名称 当前选中的index 当前选中的对应数据Id
  1054. var selectBox = this.data.gixboxService;
  1055. if (selectBox == undefined || selectBox == '') {
  1056. var selectBoxName = '';
  1057. var selectBoxId = '';
  1058. var selectBoxPrice = '';
  1059. } else {
  1060. var gixboxIndex = this.data.boxClick;
  1061. if (gixboxIndex == '-') {
  1062. that.setData({
  1063. hiddenmodal: false,
  1064. modalCont: '请选择礼盒'
  1065. })
  1066. setTimeout(function () {
  1067. that.setData({
  1068. hiddenmodal: true
  1069. })
  1070. }, 1000)
  1071. return false;
  1072. } else {
  1073. var selectBoxId = this.data.gixboxService[gixboxIndex].id;
  1074. var selectBoxName = this.data.gixboxService[gixboxIndex].giftbox_name;
  1075. var selectBoxPrice = this.data.gixboxService[gixboxIndex].box_price;
  1076. }
  1077. }
  1078. //定制 名称 当前选中的index 当前选中的对应数据Id
  1079. var selectDingZhi = this.data.dingzhiService;
  1080. if (selectDingZhi == undefined || selectDingZhi == '') {
  1081. var selectDingZhiName = '';
  1082. var selectDingZhiId = '';
  1083. } else {
  1084. var selectDingZhiIndex = this.data.dingZhiClick;
  1085. if (selectDingZhiIndex == '-') {
  1086. that.setData({
  1087. hiddenmodal: false,
  1088. modalCont: '请选择定制'
  1089. })
  1090. setTimeout(function () {
  1091. that.setData({
  1092. hiddenmodal: true
  1093. })
  1094. }, 1000)
  1095. return false;
  1096. } else {
  1097. var selectDingZhiId = this.data.dingzhiService[selectDingZhiIndex].id;
  1098. var selectDingZhiName = this.data.dingzhiService[selectDingZhiIndex].process_name;
  1099. }
  1100. }
  1101. if (id == 0) {//加入购物车
  1102. let num = parseInt(this.data.minNumber);
  1103. let oldNum = parseInt(this.data.cartNum);
  1104. let newNum = oldNum + num;
  1105. if (newNum > 99) {
  1106. this.setData({
  1107. 'cartNum': '99+'
  1108. })
  1109. } else {
  1110. this.setData({
  1111. 'cartNum': newNum
  1112. })
  1113. }
  1114. var host = getApp().globalData.servsers;
  1115. var un_id = getApp().globalData.un_id;
  1116. var name = this.data.title;
  1117. var id = this.data.com_id;
  1118. var logo = this.data.bannerSml;
  1119. var cost = this.data.newPrice;
  1120. var acceptance = this.data.acceptance;
  1121. var cyc = this.data.cycle;
  1122. var number = this.data.minNumber;
  1123. var limitNum = this.data.num;//起订量
  1124. wx.request({
  1125. url: host + "shoppingcartapi/insertshoppingcart",
  1126. data: {
  1127. user_id: un_id,
  1128. com_id: id,
  1129. name: name,
  1130. logo: logo,
  1131. cost: cost,
  1132. cyc: cyc,
  1133. num: number,
  1134. minNumber: limitNum,
  1135. acceptance: acceptance,
  1136. flag: 1,
  1137. giftbox: selectBoxId,
  1138. giftbox_name: selectBoxName,
  1139. box_price: selectBoxPrice,
  1140. process: selectDingZhiId,
  1141. process_name: selectDingZhiName,
  1142. style1_name: styleName1,
  1143. style1: styleId1,
  1144. style2_name: styleName2,
  1145. style2: styleId2,
  1146. style3_name: styleName3,
  1147. style3: styleId3,
  1148. style4_name: styleName4,
  1149. style4: styleId4,
  1150. style5: styleId4,
  1151. style5_name: styleName5,
  1152. },
  1153. method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
  1154. header: {
  1155. 'Accept': 'application/json'
  1156. },
  1157. success: function (res) {
  1158. if (res == null || res.data == null) {
  1159. console.error('网络请求失败');
  1160. return;
  1161. }
  1162. }
  1163. })
  1164. } else {
  1165. carts = [{
  1166. id: shangpin_id,
  1167. com_id: shangpin_id,
  1168. name: name,
  1169. logo: logo,
  1170. cost: cost,
  1171. cyc: cyc,
  1172. num: number,
  1173. acceptance: acceptance,
  1174. region: region,
  1175. specifications: specifications,
  1176. flag: 1,
  1177. giftbox: selectBoxId,
  1178. giftbox_name: selectBoxName,
  1179. box_price: selectBoxPrice,
  1180. style1: styleId1,
  1181. style1_name: styleName1,
  1182. style2: styleId2,
  1183. style2_name: styleName2,
  1184. style3: styleId3,
  1185. style3_name: styleName3,
  1186. style4: styleId4,
  1187. style4_name: styleName4,
  1188. style5: styleId5,
  1189. style5_name: styleName5,
  1190. process: selectDingZhiId,
  1191. process_name: selectDingZhiName,
  1192. new_price: that.data.allPrice,
  1193. user_num: that.data.user_allow_num
  1194. }];
  1195. this.setData({
  1196. carts: carts
  1197. })
  1198. var newCarts = JSON.stringify(that.data.carts);
  1199. newCarts = newCarts.replace(/&/g, "zss");
  1200. wx.navigateTo({
  1201. url: '/pages/confirmOrderOnly/confirmOrderOnly?carts=' + newCarts,
  1202. success: function (res) {
  1203. // success
  1204. },
  1205. fail: function () {
  1206. // fail
  1207. },
  1208. complete: function () {
  1209. // complete
  1210. }
  1211. })
  1212. }
  1213. wx.getSystemInfo({
  1214. success: function (res) {
  1215. animationShowHeight = res.windowHeight;
  1216. }
  1217. })
  1218. // 关闭遮罩层
  1219. var animation = wx.createAnimation({
  1220. duration: 400,
  1221. timingFunction: 'linear',
  1222. })
  1223. this.animation = animation;
  1224. animation.bottom(0).step()
  1225. this.setData({
  1226. isShow: false,
  1227. animationDataBuy: animation.export()
  1228. })
  1229. setTimeout(function () {
  1230. animation.bottom(-animationShowHeight).step()
  1231. this.setData({
  1232. animationDataBuy: animation.export()
  1233. })
  1234. }.bind(this), 200)
  1235. animation.opacity(1).step()
  1236. this.setData({
  1237. windBgShow: animation.export()
  1238. })
  1239. setTimeout(function () {
  1240. animation.opacity(0).step()
  1241. this.setData({
  1242. isShow: false,
  1243. windBgShow: animation.export()
  1244. })
  1245. }.bind(this), 200)
  1246. },
  1247. imageLoad: function (e) {
  1248. var that = this;
  1249. var imageSize = {};
  1250. var originalWidth = e.detail.width;//图片原始宽
  1251. var originalHeight = e.detail.height;//图片原始高
  1252. var originalScale = originalHeight / originalWidth;//图片高宽比
  1253. wx.getSystemInfo({
  1254. success: function (res) {
  1255. var windowWidth = res.windowWidth;
  1256. var windowHeight = res.windowHeight;
  1257. var windowscale = windowHeight / windowWidth;//屏幕高宽比
  1258. imageSize.imageHeight = (windowWidth * originalHeight) / originalWidth;
  1259. }
  1260. })
  1261. that.setData({
  1262. imageheight: imageSize.imageHeight,
  1263. })
  1264. },
  1265. windOpen: function () {
  1266. console.log("延时调用");
  1267. },
  1268. windClose: function () {
  1269. this.setData({
  1270. hidden: true
  1271. });
  1272. },
  1273. previewImg: function (e) {//banner图预览
  1274. var that = this;
  1275. var currentUrl = e.currentTarget.dataset.src;
  1276. wx.previewImage({
  1277. current: currentUrl,
  1278. urls: that.data.imgList
  1279. })
  1280. },
  1281. //显示选择商品&定制详情
  1282. showGoodsInfor: function () {
  1283. var that = this;
  1284. var scrollTop = that.data.scrollTop;
  1285. that.setData({
  1286. chooseFlag: 1
  1287. })
  1288. wx.getSystemInfo({
  1289. success: function (res) {
  1290. animationShowHeight = res.windowHeight;
  1291. }
  1292. })
  1293. // 显示遮罩层
  1294. var animation = wx.createAnimation({
  1295. duration: 400,
  1296. timingFunction: 'linear',
  1297. })
  1298. this.animation = animation
  1299. animation.opacity(0).step()
  1300. this.setData({
  1301. isShow: true,
  1302. windBgShow: animation.export()
  1303. })
  1304. setTimeout(function () {
  1305. animation.opacity(1).step()
  1306. this.setData({
  1307. windBgShow: animation.export()
  1308. })
  1309. }.bind(this), 200)
  1310. //内容
  1311. animation.bottom(-animationShowHeight).step()
  1312. this.setData({
  1313. animationDataBuy: animation.export()
  1314. })
  1315. setTimeout(function () {
  1316. animation.bottom(0).step()
  1317. this.setData({
  1318. animationDataBuy: animation.export()
  1319. })
  1320. }.bind(this), 200)
  1321. },
  1322. showServiceInfor: function () {//显示服务
  1323. var that = this;
  1324. var scrollTop = that.data.scrollTop;
  1325. that.setData({
  1326. stateId: 0
  1327. });
  1328. wx.getSystemInfo({
  1329. success: function (res) {
  1330. animationShowHeight = res.windowHeight;
  1331. }
  1332. })
  1333. var animation = wx.createAnimation({
  1334. duration: 400,
  1335. timingFunction: 'linear',
  1336. })
  1337. this.animation = animation
  1338. animation.opacity(0).step()
  1339. this.setData({
  1340. isShow: true,
  1341. windBgShow: animation.export()
  1342. })
  1343. setTimeout(function () {
  1344. animation.opacity(1).step()
  1345. this.setData({
  1346. windBgShow: animation.export()
  1347. })
  1348. }.bind(this), 200)
  1349. animation.bottom(-animationShowHeight).step()
  1350. this.setData({
  1351. animationDataSer: animation.export()
  1352. })
  1353. setTimeout(function () {
  1354. animation.bottom(0).step()
  1355. this.setData({
  1356. animationDataSer: animation.export()
  1357. })
  1358. }.bind(this), 200)
  1359. },
  1360. closeBuy: function () {//关闭购买弹窗
  1361. var that = this;
  1362. wx.getSystemInfo({
  1363. success: function (res) {
  1364. animationShowHeight = res.windowHeight;
  1365. }
  1366. })
  1367. var animation = wx.createAnimation({
  1368. duration: 400,
  1369. timingFunction: 'linear',
  1370. })
  1371. this.animation = animation
  1372. animation.opacity(1).step()
  1373. this.setData({
  1374. windBgShow: animation.export()
  1375. })
  1376. setTimeout(function () {
  1377. animation.opacity(0).step()
  1378. this.setData({
  1379. isShow: false,
  1380. windBgShow: animation.export()
  1381. })
  1382. }.bind(this), 200)
  1383. // 显示遮罩层
  1384. animation.bottom(0).step()
  1385. this.setData({
  1386. animationDataBuy: animation.export()
  1387. })
  1388. setTimeout(function () {
  1389. animation.bottom(-animationShowHeight).step()
  1390. this.setData({
  1391. animationDataBuy: animation.export()
  1392. })
  1393. }.bind(this), 200)
  1394. },
  1395. closeService: function () {//关闭服务弹窗
  1396. var that = this;
  1397. that.setData({
  1398. chooseFlag: 0
  1399. })
  1400. wx.getSystemInfo({
  1401. success: function (res) {
  1402. animationShowHeight = res.windowHeight;
  1403. }
  1404. })
  1405. var animation = wx.createAnimation({
  1406. duration: 400,
  1407. timingFunction: 'linear',
  1408. })
  1409. this.animation = animation
  1410. animation.opacity(1).step()
  1411. this.setData({
  1412. windBgShow: animation.export()
  1413. })
  1414. setTimeout(function () {
  1415. animation.opacity(0).step()
  1416. this.setData({
  1417. isShow: false,
  1418. windBgShow: animation.export()
  1419. })
  1420. }.bind(this), 200)
  1421. // 内容
  1422. animation.bottom(0).step()
  1423. this.setData({
  1424. animationDataSer: animation.export()
  1425. })
  1426. setTimeout(function () {
  1427. animation.bottom(-animationShowHeight).step()
  1428. this.setData({
  1429. animationDataSer: animation.export()
  1430. })
  1431. }.bind(this), 200)
  1432. },
  1433. onShareAppMessage: function (res) {//页面分享
  1434. var that = this;
  1435. var host = getApp().globalData.servsers;
  1436. if (res.from === 'button') {
  1437. // 来自页面内转发按钮
  1438. }
  1439. return {
  1440. title: that.data.title,
  1441. path: '/pages/buyOnly/buyOnly?com_id=' + that.data.com_id,
  1442. imageUrl: host + 'images/' + that.data.bannerShare,
  1443. success: function (res) {
  1444. // 转发成功
  1445. that.setData({
  1446. hiddenmodal: false,
  1447. modalCont: '分享成功'
  1448. })
  1449. setTimeout(function () {
  1450. that.setData({
  1451. hiddenmodal: true
  1452. })
  1453. }, 1000)
  1454. },
  1455. fail: function (res) {
  1456. // 取消分享、转发失败
  1457. }
  1458. }
  1459. }
  1460. })
  1461. var that;
  1462. var imageUtil = require('../../utils/util.js');