details.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089
  1. // 团长接龙详情
  2. var app = getApp();
  3. var util = require('../../utils/util.js');
  4. var status = require('../../utils/index.js');
  5. Page({
  6. mixins: [require('../../mixin/compoentCartMixin.js'), require('../../mixin/globalMixin.js')],
  7. data: {
  8. showGoodsModal: false,
  9. showCommentModal: false,
  10. showCartModal: false,
  11. pid: 0,
  12. hideGoods: true,
  13. buy_type: 'soitaire',
  14. groupInfo: {
  15. group_name: '社区',
  16. owner_name: '团长'
  17. },
  18. showShareModal: false,
  19. list: [],
  20. loadText: "加载中...",
  21. noData: 0,
  22. loadMore: true,
  23. isIpx: app.globalData.isIpx,
  24. orderList: [],
  25. noOrderMore: false,
  26. noOrderData: 0,
  27. myOrderList: [],
  28. noMyOrderMore: false,
  29. noMyOrderData: false
  30. },
  31. imagePath: '',
  32. options: '',
  33. page: 1,
  34. soli_id: 0,
  35. orderPage: 1,
  36. isFirst: 1,
  37. myOrderPage: 1,
  38. canCancel: true,
  39. /**
  40. * 生命周期函数--监听页面加载
  41. */
  42. onLoad: function (options) {
  43. app.setShareConfig();
  44. let that = this;
  45. status.setNavBgColor();
  46. status.setGroupInfo().then((groupInfo) => { that.setData({ groupInfo }) });
  47. var scene = decodeURIComponent(options.scene);
  48. if (scene !== 'undefined') {
  49. var opt_arr = scene.split("_");
  50. options.id = opt_arr[0]; //接龙id
  51. options.share_id = opt_arr[1]; //分享人id
  52. }
  53. let { id, share_id } = options;
  54. this.options = options;
  55. if (share_id != 'undefined' && share_id > 0) wx.setStorageSync('share_id', share_id);
  56. if (!id) {
  57. app.util.message('参数错误', 'redirect:/lionfish_comshop/moduleA/solitaire/index', 'error');
  58. }
  59. this.soli_id = id;
  60. },
  61. initFn(){
  62. let that = this;
  63. let id = this.options && this.options.id || 0;
  64. this.page = 1;
  65. this.setData({
  66. list: [],
  67. loadText: "加载中...",
  68. noData: 0,
  69. loadMore: true
  70. }, ()=>{
  71. id && that.getData(id);
  72. })
  73. },
  74. /**
  75. * 生命周期函数--监听页面显示
  76. */
  77. onShow: function () {
  78. let that = this;
  79. let id = this.options && this.options.id || 0;
  80. id && this.getData(id),this.getOrderList(), this.getMyOrderList();
  81. util.check_login_new().then((res) => {
  82. if (!res) {
  83. that.setData({
  84. needAuth: true
  85. })
  86. } else {
  87. that.showCartGoods().catch(()=>{
  88. console.log('购物车为空')
  89. });
  90. }
  91. })
  92. },
  93. onHide: function () {
  94. this.setData({ clearTime: true })
  95. },
  96. authSuccess: function(){
  97. this.setData({ needAuth: false })
  98. let head_data = this.data.community;
  99. console.log('authSuccess');
  100. this.compareCommunity(head_data);
  101. this.visiteRecord();
  102. },
  103. /**
  104. * 获取详情
  105. */
  106. getData: function (id) {
  107. const token = wx.getStorageSync('token');
  108. let that = this;
  109. app.util.request({
  110. url: 'entry/wxapp/index',
  111. data: {
  112. controller: 'solitaire.get_solitaire_detail',
  113. id,
  114. token
  115. },
  116. dataType: 'json',
  117. success: function (res) {
  118. if (res.data.code == 0) {
  119. let { head_data, soli_info, solitaire_target, solitaire_target_takemember, solitaire_target_takemoney, solitaire_target_type,solitaire_is_message } = res.data;
  120. // 完成接龙差值
  121. let {
  122. soli_total_money, //一共下单金额
  123. order_count //一共下多少单
  124. } = soli_info;
  125. let diffMoney = solitaire_target_takemoney * 1 - soli_total_money*1;
  126. let diffMember = solitaire_target_takemember * 1 - order_count * 1;
  127. that.setData({
  128. community: head_data || '',
  129. soli_info,
  130. solitaire_target,
  131. solitaire_target_takemember,
  132. solitaire_target_takemoney,
  133. solitaire_target_type,
  134. diffMoney,
  135. diffMember,
  136. clearTime: false,
  137. solitaire_is_message
  138. })
  139. if(that.isFirst==1) {
  140. that.compareCommunity(head_data);
  141. if(solitaire_is_message==1){
  142. that.getCommentList()
  143. }
  144. setTimeout(() => {
  145. that.drawImg(head_data, soli_info);
  146. }, 1000);
  147. token && that.visiteRecord();
  148. }
  149. that.isFirst++;
  150. } else {
  151. app.util.message(res.data.msg, 'redirect:/lionfish_comshop/moduleA/solitaire/index', 'error');
  152. return;
  153. }
  154. }
  155. })
  156. },
  157. showImgPrev: function (event) {
  158. var idx = event ? event.currentTarget.dataset.idx : '';
  159. let urls = this.data.soli_info.images_list || '';
  160. wx.previewImage({
  161. current: urls[idx],
  162. urls
  163. });
  164. },
  165. /**
  166. * 比较社区
  167. * shareCommunity: 这个接龙的所属社区
  168. */
  169. compareCommunity: function(shareCommunity) {
  170. let that = this;
  171. // 原来社区
  172. let currentCommunity = wx.getStorageSync('community');
  173. let currentCommunityId = currentCommunity.communityId || '';
  174. const token = wx.getStorageSync('token');
  175. let { groupInfo } = that.data;
  176. let shareCommunityId = shareCommunity.head_id || '';
  177. shareCommunityId && util.getCommunityById(shareCommunityId).then(res=>{
  178. let { hide_community_change_btn, default_head_info } = res;
  179. if (res.open_danhead_model == 1) {
  180. // 开启单社区
  181. app.globalData.community = default_head_info;
  182. app.globalData.changedCommunity = true;
  183. wx.setStorage({ key: "community", data: default_head_info })
  184. token && util.addhistory(default_head_info);
  185. if(shareCommunityId!=default_head_info.communityId) {
  186. let { groupInfo } = that.data;
  187. console.log('开启单社区');
  188. app.util.message(`您只能访问自己${groupInfo.group_name}`, 'redirect:/lionfish_comshop/moduleA/solitaire/index', 'error', '知道了');
  189. return;
  190. }
  191. } else {
  192. // 社区是否存在
  193. if (currentCommunityId != '' && shareCommunityId) {
  194. // 存在并且不相同
  195. console.log('currentCommunityId存在 比较社区')
  196. if (currentCommunityId != shareCommunityId) {
  197. console.log('currentCommunityId存在 社区不同')
  198. //如果禁止切换
  199. // if (hide_community_change_btn == 1) {
  200. console.log('禁止切换');
  201. app.util.message(`您只能访问自己${groupInfo.group_name}`, 'redirect:/lionfish_comshop/moduleA/solitaire/index', 'error', '知道了');
  202. return;
  203. // }
  204. // that.setData({
  205. // hide_community_change_btn,
  206. // showChangeCommunity: res.data ? true : false,
  207. // changeCommunity: res.data,
  208. // currentCommunity: currentCommunity
  209. // })
  210. }
  211. } else {
  212. // 不存在社区id
  213. //token 是否存在
  214. if (token) {
  215. util.getCommunityInfo().then(function (ret) {
  216. //比较社区
  217. console.log('token存在 比较社区')
  218. if (ret.community_id && ret.community_id != shareCommunityId) {
  219. app.util.message(`您只能访问自己${groupInfo.group_name}`, 'redirect:/lionfish_comshop/moduleA/solitaire/index', 'error', '知道了');
  220. return;
  221. // that.setData({
  222. // showChangeCommunity: true,
  223. // currentCommunity: ret
  224. // })
  225. }
  226. }).catch((param) => {
  227. console.log('step4 新人')
  228. if (Object.keys(param) != '') util.addhistory(param, true);
  229. });
  230. } else {
  231. console.log('token不存在 存社区')
  232. // 直接存本地
  233. app.globalData.community = res.data;
  234. app.globalData.changedCommunity = true;
  235. wx.setStorage({ key: "community", data: res.data })
  236. }
  237. }
  238. }
  239. });
  240. },
  241. /**
  242. * 切换提示
  243. */
  244. confrimChangeCommunity: function () {
  245. let community = this.data.changeCommunity;
  246. let token = wx.getStorageSync('token');
  247. app.globalData.community = community;
  248. app.globalData.changedCommunity = true;
  249. wx.setStorage({
  250. key: "community",
  251. data: community
  252. })
  253. token && util.addhistory(community);
  254. this.setData({ showChangeCommunity: false })
  255. console.log('用户点击确定')
  256. },
  257. /**
  258. * 取消切换
  259. */
  260. cancelChangeCommunity: function () {
  261. let { groupInfo } = this.data;
  262. wx.showModal({
  263. title: '提示',
  264. content: `此接龙在您所属${groupInfo.group_name}不可参与`,
  265. showCancel: false,
  266. confirmColor: '#ff5041',
  267. success(res) {
  268. if (res.confirm) {
  269. wx.switchTab({
  270. url: `/lionfish_comshop/pages/index/index`
  271. })
  272. }
  273. }
  274. });
  275. },
  276. /**
  277. * 商品弹窗
  278. */
  279. handleGoodsModal: function () {
  280. this.setData({
  281. showGoodsModal: !this.data.showGoodsModal
  282. })
  283. },
  284. /**
  285. * 评论弹窗
  286. */
  287. handleCommentModal: function () {
  288. this.setData({
  289. showCommentModal: !this.data.showCommentModal
  290. })
  291. },
  292. changeCartNum: function(e){
  293. let { goods_total_count, goods_id } = e.detail;
  294. let soli_info = this.data.soli_info || '';
  295. let goods_list = soli_info.goods_list || [];
  296. let gidx = goods_list.findIndex(item => item.actId == goods_id);
  297. if (gidx !== -1) {
  298. this.showCartGoods().catch(()=>{
  299. console.log('购物车为空')
  300. });
  301. goods_list[gidx].goods_total_count = goods_total_count || 0;
  302. soli_info.goods_list = goods_list;
  303. // let cartNum = 0;
  304. // goods_list.forEach(item=>{
  305. // cartNum += item.goods_total_count*1;
  306. // })
  307. this.setData({ soli_info })
  308. }
  309. },
  310. /**
  311. * 购物车弹窗
  312. */
  313. handleCartModal: function() {
  314. console.log('购物车弹窗');
  315. let that = this;
  316. let showCartModal = this.data.showCartModal;
  317. if (showCartModal){
  318. this.setData({ showCartModal: false })
  319. } else {
  320. this.showCartGoods().then(()=>{
  321. that.setData({ showCartModal: true })
  322. }).catch(()=>{
  323. console.log('购物车为空')
  324. });
  325. }
  326. },
  327. /**
  328. * showModal
  329. */
  330. showCartGoods: function (showModal=true){
  331. let that = this;
  332. return new Promise(function (resolve, reject) {
  333. const token = wx.getStorageSync('token');
  334. let soli_id = that.soli_id || '';
  335. let currentCommunity = wx.getStorageSync('community');
  336. let community_id = currentCommunity.communityId || '';
  337. soli_id && wx.showLoading(), app.util.request({
  338. url: 'entry/wxapp/index',
  339. data: {
  340. controller: 'car.show_cart_goods',
  341. token,
  342. soli_id,
  343. community_id,
  344. buy_type: 'soitaire',
  345. },
  346. dataType: 'json',
  347. success: function (res) {
  348. wx.hideLoading();
  349. if (res.data.code == 0) {
  350. let carts = res.data.carts;
  351. if (Object.keys(carts).length == 0){
  352. that.setData({ cartNum: 0 })
  353. reject(res);
  354. } else {
  355. let { cartNum, totMoney } = that.countCartNum(carts);
  356. showModal && that.setData({ carts, cartNum, totMoney })
  357. resolve();
  358. }
  359. } else if(res.data.code == 5) {
  360. that.setData({ needAuth: true, showAuthModal: true })
  361. } else {
  362. console.log(res)
  363. }
  364. }
  365. })
  366. })
  367. },
  368. /**
  369. * 计算数量和金额
  370. * @param {*} carts
  371. */
  372. countCartNum: function(carts){
  373. let cartNum = 0;
  374. let totMoney = 0;
  375. Object.keys(carts).forEach(k=>{
  376. Object.keys(carts[k].shopcarts).forEach(j=>{
  377. let gnum = carts[k].shopcarts[j].goodsnum*1;
  378. cartNum += gnum;
  379. totMoney += carts[k].shopcarts[j].currntprice*gnum;
  380. });
  381. })
  382. totMoney = totMoney.toFixed(2);
  383. return { cartNum, totMoney };
  384. },
  385. /**
  386. * 购物车改变
  387. * 重新请求列表
  388. */
  389. changeCart: function(e){
  390. let id = this.options && this.options.id || 0;
  391. let carts = e.detail;
  392. let { cartNum, totMoney } = this.countCartNum(carts);
  393. id && this.setData({ clearTime: true, carts, cartNum, totMoney }), this.getData(id);
  394. },
  395. /**
  396. * 留言
  397. */
  398. subComment: function (e) {
  399. let { soli_info, pid } = this.data;
  400. let soli_id = soli_info.id || '';
  401. let content = e.detail.value.content || '';
  402. if (content == '') {
  403. wx.showToast({
  404. title: '请输入内容',
  405. icon: 'none'
  406. })
  407. return;
  408. }
  409. let that = this;
  410. const token = wx.getStorageSync('token');
  411. app.util.request({
  412. url: 'entry/wxapp/index',
  413. data: {
  414. controller: 'solitaire.sub_solipost',
  415. soli_id,
  416. content,
  417. pid,
  418. token
  419. },
  420. dataType: 'json',
  421. success: function (res) {
  422. if (res.data.code == 0) {
  423. let { post_id, cur_time } = res.data;
  424. let userInfo = wx.getStorageSync('userInfo');
  425. let comment = {
  426. id: post_id,
  427. soli_id,
  428. pid,
  429. username: userInfo.nickName,
  430. avatar: userInfo.avatarUrl,
  431. content,
  432. fav_count: 0,
  433. addtime: cur_time,
  434. reply: [],
  435. is_agree: false
  436. }
  437. let list = that.data.list;
  438. list.unshift(comment);
  439. soli_info.comment_total = soli_info.comment_total*1 + 1;
  440. that.setData({ soli_info, list, content: '', showCommentModal: false, noData: 0 })
  441. app.util.message(res.data.msg || '留言成功', '', 'success');
  442. } else {
  443. app.util.message(res.data.msg || '留言失败', '', 'error');
  444. }
  445. }
  446. })
  447. },
  448. /**
  449. * 记录浏览次数
  450. */
  451. visiteRecord: function () {
  452. let soli_id = this.soli_id || '';
  453. const token = wx.getStorageSync('token');
  454. app.util.request({
  455. url: 'entry/wxapp/index',
  456. data: {
  457. controller: 'solitaire.send_visite_record',
  458. soli_id,
  459. token
  460. },
  461. dataType: 'json',
  462. success: function (res) { }
  463. })
  464. },
  465. /**
  466. * 点赞
  467. */
  468. favComment: function (e) {
  469. let that = this;
  470. let soli_info = this.data.soli_info;
  471. let soli_id = soli_info.id || '';
  472. let post_id = e ? e.currentTarget.dataset.post_id : '';
  473. let idx = e ? e.currentTarget.dataset.idx : 0;
  474. const token = wx.getStorageSync('token');
  475. post_id && app.util.request({
  476. url: 'entry/wxapp/index',
  477. data: {
  478. controller: 'solitaire.fav_soli_post',
  479. soli_id,
  480. post_id,
  481. token
  482. },
  483. dataType: 'json',
  484. success: function (res) {
  485. if (res.data.code == 0) {
  486. if (res.data.do == 1) {
  487. // 点赞成功
  488. let list = that.data.list;
  489. list[idx].is_agree = true;
  490. list[idx].fav_count = list[idx].fav_count * 1 + 1;
  491. that.setData({ list })
  492. } else {
  493. // 取消成功
  494. let list = that.data.list;
  495. list[idx].is_agree = false;
  496. list[idx].fav_count = list[idx].fav_count*1 - 1;
  497. that.setData({ list })
  498. }
  499. } else if (res.data.code == 1) {
  500. that.setData({ needAuth: true, showAuthModal: true })
  501. } else {
  502. wx.showToast({
  503. title: res.data.msg || '点赞失败',
  504. icon: 'none'
  505. })
  506. }
  507. }
  508. })
  509. },
  510. /**
  511. * 更多商品显示隐藏
  512. */
  513. handleMoreGoods: function(){
  514. this.setData({ hideGoods: !this.data.hideGoods })
  515. },
  516. goPlaceOrder: function(){
  517. let soli_info = this.data.soli_info;
  518. // if (soli_info.is_involved) return;
  519. this.showCartGoods(false).then(()=>{
  520. let soli_id = soli_info.id || '';
  521. let url = `/lionfish_comshop/pages/order/placeOrder?type=soitaire&soli_id=${soli_id}`;
  522. wx.navigateTo({ url })
  523. }).catch(()=>{
  524. wx.showToast({
  525. title: '请先选择商品!',
  526. icon: 'none'
  527. })
  528. });
  529. },
  530. /**
  531. * 获取评论列表
  532. */
  533. getCommentList: function () {
  534. let that = this;
  535. let id = this.options && this.options.id || 0;
  536. const token = wx.getStorageSync('token');
  537. wx.showLoading();
  538. app.util.request({
  539. url: 'entry/wxapp/index',
  540. data: {
  541. controller: 'solitaire.get_comment_list',
  542. page: this.page,
  543. token,
  544. id
  545. },
  546. dataType: 'json',
  547. success: function (res) {
  548. wx.hideLoading();
  549. if (res.data.code == 0) {
  550. let h = {};
  551. let list = res.data.data;
  552. if (list.length < 20) h.noMore = true;
  553. let oldList = that.data.list;
  554. list = oldList.concat(list);
  555. that.page++;
  556. that.setData({
  557. list,
  558. ...h
  559. })
  560. } else if (res.data.code == 1) {
  561. // 无数据
  562. if (that.page == 1) that.setData({
  563. noData: 1
  564. })
  565. that.setData({
  566. loadMore: false,
  567. noMore: false,
  568. loadText: "没有更多记录了~"
  569. })
  570. }
  571. }
  572. })
  573. },
  574. /**
  575. * 用户订单列表
  576. */
  577. getMyOrderList: function () {
  578. console.log('getMyOrderList');
  579. let that = this;
  580. let soli_id = this.options && this.options.id || 0;
  581. const token = wx.getStorageSync('token');
  582. token && wx.showLoading(), app.util.request({
  583. url: 'entry/wxapp/index',
  584. data: {
  585. controller: 'order.orderlist',
  586. page: this.myOrderPage,
  587. token,
  588. soli_id
  589. },
  590. dataType: 'json',
  591. success: function (res) {
  592. wx.hideLoading();
  593. if (res.data.code == 0) {
  594. let h = {};
  595. let list = res.data.data;
  596. if (list.length < 6) h.noMyOrderMore = true;
  597. let oldList = that.data.myOrderList;
  598. list = oldList.concat(list);
  599. that.myOrderPage++;
  600. that.setData({
  601. myOrderList: list,
  602. ...h
  603. })
  604. } else if (res.data.code == 1) {
  605. // 无数据
  606. let h = { noMyOrderMore: true };
  607. if (that.myOrderPage == 1) h.noMyOrderData = 1;
  608. that.setData(h)
  609. }
  610. }
  611. })
  612. },
  613. getMoreMyOrder: function(){
  614. this.data.noMyOrderMore || this.getMyOrderList();
  615. },
  616. //取消订单
  617. cancelOrder: function(e){
  618. let that = this;
  619. this.canCancel && wx.showModal({
  620. title: '取消订单并退款',
  621. content: '取消订单后,款项将原路退回到您的支付账户;详情请查看退款进度。',
  622. confirmText: '取消订单',
  623. confirmColor: '#ff5344',
  624. cancelText: '再等等',
  625. cancelColor: '#666666',
  626. success(res) {
  627. if (res.confirm) {
  628. that.canCancel = false;
  629. let order_id = e.currentTarget.dataset.type;
  630. let idx = e.currentTarget.dataset.index;
  631. let token = wx.getStorageSync('token');
  632. app.util.request({
  633. url: 'entry/wxapp/index',
  634. data: {
  635. controller: 'order.del_cancle_order',
  636. token,
  637. order_id
  638. },
  639. dataType: 'json',
  640. method: 'POST',
  641. success: function (res) {
  642. if(res.data.code==0){
  643. //提交成功
  644. wx.showModal({
  645. title: '提示',
  646. content: '取消订单成功',
  647. showCancel: false,
  648. confirmColor: '#ff5344',
  649. success(ret) {
  650. if(ret.confirm) {
  651. let myOrderList = that.data.myOrderList;
  652. myOrderList[idx].order_status_id = 5;
  653. that.setData({ myOrderList })
  654. }
  655. }
  656. })
  657. } else {
  658. that.canCancel = true;
  659. wx.showToast({
  660. title: res.data.msg || '取消订单失败',
  661. icon: 'none'
  662. })
  663. }
  664. }
  665. })
  666. console.log('用户点击确定')
  667. } else if (res.cancel) {
  668. that.canCancel = true;
  669. console.log('用户点击取消')
  670. }
  671. }
  672. })
  673. },
  674. callTelphone: function(event) {
  675. let phoneNumber = event.currentTarget.dataset.phone;
  676. wx.makePhoneCall({ phoneNumber })
  677. },
  678. /**
  679. * 获取评论列表
  680. */
  681. getOrderList: function () {
  682. let that = this;
  683. let id = this.options && this.options.id || 0;
  684. wx.showLoading();
  685. app.util.request({
  686. url: 'entry/wxapp/index',
  687. data: {
  688. controller: 'solitaire.get_soli_order_list',
  689. page: this.orderPage,
  690. id,
  691. size: 6
  692. },
  693. dataType: 'json',
  694. success: function (res) {
  695. wx.hideLoading();
  696. if (res.data.code == 0) {
  697. let h = {};
  698. let list = res.data.data;
  699. if (list.length < 6) h.noOrderMore = true;
  700. let oldList = that.data.orderList;
  701. let orderList = oldList.concat(list);
  702. that.orderPage++;
  703. that.setData({
  704. orderList,
  705. ...h
  706. })
  707. } else if (res.data.code == 1) {
  708. // 无数据
  709. let h = {};
  710. if (that.orderPage == 1) h.noOrderData = 1;
  711. that.setData({
  712. noOrderMore: true,
  713. ...h
  714. })
  715. }
  716. }
  717. })
  718. },
  719. getMoreOrder: function(){
  720. this.data.noOrderMore || this.getOrderList();
  721. },
  722. /**
  723. * 页面上拉触底事件的处理函数
  724. */
  725. onReachBottom: function () {
  726. if (!this.data.loadMore||this.data.solitaire_is_message==0) return false;
  727. this.getCommentList();
  728. },
  729. drawImg: function (head, soli_info) {
  730. let images_list = soli_info.images_list;
  731. let qrcode_image = soli_info.qrcode_image;
  732. let content = soli_info.content.replace(/&lt;[^&gt]+&gt;|&[^&gt]+;/g, "").trim();
  733. content = content.replace(/<\/?.+?>/g, "");
  734. content = content.replace(/&nbsp;/g, "");
  735. let option = [];
  736. let h = 300
  737. if (images_list.length) {
  738. option.push({
  739. "type": "image",
  740. "url": images_list[0],
  741. "css":
  742. {
  743. "width": "442px",
  744. "height": "300px",
  745. "top": "230px",
  746. "left": "36px",
  747. "rotate": "0",
  748. "borderRadius": "",
  749. "borderWidth": "",
  750. "borderColor": "",
  751. "shadow": "",
  752. "mode": "aspectFill"
  753. }
  754. })
  755. h = 0;
  756. }
  757. this.setData({
  758. template: {
  759. "width": "514px",
  760. "height": (710-h) + "px",
  761. "background": "#fff",
  762. "views": [
  763. {
  764. "type": "image",
  765. "url": head.avatar,
  766. "css":
  767. {
  768. "width": "46px",
  769. "height": "46px",
  770. "top": "25px",
  771. "left": "36px",
  772. "rotate": "0",
  773. "borderRadius": "3px",
  774. "borderWidth": "",
  775. "borderColor": "#000000",
  776. "shadow": "",
  777. "mode": "scaleToFill"
  778. }
  779. },
  780. {
  781. "type": "text",
  782. "text": head.head_name,
  783. "css":
  784. {
  785. "color": "#000000",
  786. "background": "",
  787. "width": "385px",
  788. "height": "20px",
  789. "top": "30px",
  790. "left": "96px",
  791. "rotate": "0",
  792. "borderRadius": "",
  793. "borderWidth": "",
  794. "borderColor": "#000000",
  795. "shadow": "",
  796. "padding": "0px",
  797. "fontSize": "14px",
  798. "fontWeight": "bold",
  799. "maxLines": "1",
  800. "lineHeight": "20px",
  801. "textStyle": "fill",
  802. "textDecoration": "none",
  803. "fontFamily": "",
  804. "textAlign": "left"
  805. }
  806. },
  807. {
  808. "type": "text",
  809. "text": head.community_name,
  810. "css":
  811. {
  812. "color": "#999999",
  813. "background": "",
  814. "width": "385px",
  815. "height": "17px",
  816. "top": "52px",
  817. "left": "96px",
  818. "rotate": "0",
  819. "borderRadius": "",
  820. "borderWidth": "",
  821. "borderColor": "#000000",
  822. "shadow": "",
  823. "padding": "0px",
  824. "fontSize": "12px",
  825. "fontWeight": "normal",
  826. "maxLines": "1",
  827. "lineHeight": "17px",
  828. "textStyle": "fill",
  829. "textDecoration": "none",
  830. "fontFamily": "",
  831. "textAlign": "left"
  832. }
  833. },
  834. {
  835. "type": "text",
  836. "text": content,
  837. "css":
  838. {
  839. "color": "#666666",
  840. "background": "",
  841. "width": "442px",
  842. "height": "52px",
  843. "top": "158px",
  844. "left": "36px",
  845. "rotate": "0",
  846. "borderRadius": "",
  847. "borderWidth": "",
  848. "borderColor": "#000000",
  849. "shadow": "",
  850. "padding": "0px",
  851. "fontSize": "18px",
  852. "fontWeight": "normal",
  853. "maxLines": "2",
  854. "lineHeight": "26px",
  855. "textStyle": "fill",
  856. "textDecoration": "none",
  857. "fontFamily": "",
  858. "textAlign": "left"
  859. }
  860. },
  861. {
  862. "type": "text",
  863. "text": soli_info.solitaire_name,
  864. "css":
  865. {
  866. "color": "#000000",
  867. "background": "",
  868. "width": "442px",
  869. "height": "43px",
  870. "top": "95px",
  871. "left": "36px",
  872. "rotate": "0",
  873. "borderRadius": "",
  874. "borderWidth": "",
  875. "borderColor": "#000000",
  876. "shadow": "",
  877. "padding": "0px",
  878. "fontSize": "30px",
  879. "fontWeight": "normal",
  880. "maxLines": "1",
  881. "lineHeight": "43px",
  882. "textStyle": "fill",
  883. "textDecoration": "none",
  884. "fontFamily": "",
  885. "textAlign": "left"
  886. }
  887. },
  888. {
  889. "type": "text",
  890. "text": "一群人正在赶来接龙",
  891. "css":
  892. {
  893. "color": "#999999",
  894. "background": "",
  895. "width": "442px",
  896. "height": "23px",
  897. "top": (595-h) + "px",
  898. "left": "204px",
  899. "rotate": "0",
  900. "borderRadius": "",
  901. "borderWidth": "",
  902. "borderColor": "#000000",
  903. "shadow": "",
  904. "padding": "0px",
  905. "fontSize": "16px",
  906. "fontWeight": "normal",
  907. "maxLines": "2",
  908. "lineHeight": "23px",
  909. "textStyle": "fill",
  910. "textDecoration": "none",
  911. "fontFamily": "",
  912. "textAlign": "left"
  913. }
  914. },
  915. {
  916. "type": "text",
  917. "text": "长按识别或扫码参与",
  918. "css":
  919. {
  920. "color": "#999999",
  921. "background": "",
  922. "width": "442px",
  923. "height": "22.88px",
  924. "top": (630-h) + "px",
  925. "left": "204px",
  926. "rotate": "0",
  927. "borderRadius": "",
  928. "borderWidth": "",
  929. "borderColor": "#000000",
  930. "shadow": "",
  931. "padding": "0px",
  932. "fontSize": "16px",
  933. "fontWeight": "normal",
  934. "maxLines": "2",
  935. "lineHeight": "23px",
  936. "textStyle": "fill",
  937. "textDecoration": "none",
  938. "fontFamily": "",
  939. "textAlign": "left"
  940. }
  941. },
  942. {
  943. "type": "image",
  944. "url": qrcode_image,
  945. "css":
  946. {
  947. "width": "120px",
  948. "height": "120px",
  949. "top": (560-h) + "px",
  950. "left": "356px",
  951. "rotate": "0",
  952. "borderRadius": "",
  953. "borderWidth": "",
  954. "borderColor": "#000000",
  955. "shadow": "",
  956. "mode": "scaleToFill"
  957. }
  958. },
  959. ...option
  960. ]
  961. }
  962. });
  963. },
  964. onImgOK(e) {
  965. this.imagePath = e.detail.path;
  966. this.setData({
  967. image: this.imagePath
  968. })
  969. },
  970. saveImage() {
  971. let that = this;
  972. wx.saveImageToPhotosAlbum({
  973. filePath: this.imagePath,
  974. success(res) {
  975. that.setData({ showShareModal: false })
  976. wx.showToast({
  977. title: '保存成功!'
  978. })
  979. },
  980. fail(res) {
  981. wx.showToast({
  982. title: '保存失败,请重试!',
  983. icon: 'none'
  984. })
  985. }
  986. });
  987. },
  988. handleShareModal: function (e) {
  989. let type = e ? e.currentTarget.dataset.type : '';
  990. let h = {};
  991. if(type=='order') {
  992. h.showOrderModal = !this.data.showOrderModal
  993. } else {
  994. h.showShareModal = !this.data.showShareModal
  995. this.data.showShareModal || wx.showLoading({ title: '生成中' })
  996. }
  997. if(!this.data.showShareModal){
  998. setTimeout(() => {
  999. wx.hideLoading()
  1000. this.setData(h)
  1001. }, 1000)
  1002. } else {
  1003. this.setData(h)
  1004. }
  1005. },
  1006. /**
  1007. * 用户点击右上角分享
  1008. */
  1009. onShareAppMessage: function () {
  1010. let share_id = wx.getStorageSync('member_id') || '';
  1011. let soli_info = this.data.soli_info || '';
  1012. let title = (soli_info&&soli_info.solitaire_name) || '';
  1013. let id = soli_info&&soli_info.id || '';
  1014. let share_path = `lionfish_comshop/moduleA/solitaire/details?id=${id}&share_id=${share_id}`;
  1015. console.log(share_path)
  1016. return {
  1017. title,
  1018. path: share_path,
  1019. success: function (res) {
  1020. // 转发成功
  1021. },
  1022. fail: function (res) {
  1023. // 转发失败
  1024. }
  1025. }
  1026. },
  1027. onShareTimeline: function () {
  1028. let share_id = wx.getStorageSync('member_id') || '';
  1029. let soli_info = this.data.soli_info || '';
  1030. let title = (soli_info&&soli_info.solitaire_name) || '';
  1031. let id = soli_info&&soli_info.id || '';
  1032. var query= `id=${id}&share_id=${share_id}`;
  1033. return {
  1034. title,
  1035. query,
  1036. success: function (res) {
  1037. // 转发成功
  1038. },
  1039. fail: function (res) {
  1040. // 转发失败
  1041. }
  1042. }
  1043. }
  1044. })