C端小程序
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

431 wiersze
10 KiB

  1. var config = require("../../config/config.js");
  2. const Http = require("../../utils/HttpBasics");
  3. const imgurl = require("../../utils/imgurl");
  4. const { spellStatus,spellStatus02 } = require("../../utils/spell");
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. noCoupon: imgurl.noCoupon.url,
  11. bannerUrl: imgurl.banner.url,
  12. loadingUrl: imgurl.loading.url,
  13. nodata: imgurl.nodata.url,
  14. wmhome: imgurl.wmhome.url,
  15. orangeImg: imgurl.orange.url,
  16. blueImg: imgurl.blue.url,
  17. grayImg: imgurl.gray.url,
  18. spellList: true,
  19. myspellList: false,
  20. list: [],
  21. lists: [],
  22. myLists:[],
  23. page: 1, // 设置加载的第几次,默认是第一次
  24. pageSize: 10, //返回数据的个数
  25. searchLoadingComplete: false, //“没有数据”的变量,默认false,隐藏
  26. allow_load: true, // 是否允许继续加载标识 默认 true 允许,false 加载完成
  27. myorder: false,
  28. actUrl: imgurl.act.url,
  29. loading:true,
  30. content:'数据正在加载中',
  31. flag: 'spellList',
  32. reloadIf:false
  33. },
  34. goback: function () {
  35. wx.switchTab({
  36. url: '/pages/main/index',
  37. })
  38. },
  39. onLoad: function (options) {
  40. let that = this;
  41. that.getBannerlist();
  42. var todayDate = new Date().getTime();
  43. that.setData({
  44. optionsData: options,
  45. todayDate: todayDate
  46. })
  47. if(options&&options.from=='myhtml'){
  48. that.getmyList();
  49. }else{
  50. // 去支付
  51. if (options && options.from == 'myspellList'){
  52. that.getList(1, "myspellList");
  53. that.setData({
  54. flag: "myspellList",
  55. spellList: false,
  56. myspellList: true,
  57. lists: null
  58. })
  59. wx.setNavigationBarTitle({
  60. title: '我的拼团'
  61. })
  62. }else{
  63. that.getList(1, "spellList");
  64. that.setData({
  65. flag: "spellList",
  66. spellList: true,
  67. myspellList: false,
  68. lists: null
  69. })
  70. wx.setNavigationBarTitle({
  71. title: '拼团专场'
  72. })
  73. }
  74. }
  75. that.getUserInfo();
  76. },
  77. onShow(){
  78. let that=this;
  79. if (this.data.reloadIf){
  80. wx.setNavigationBarTitle({
  81. title: '拼团专场'
  82. })
  83. that.getList(1, "spellList");
  84. that.setData({
  85. flag: "spellList",
  86. spellList: true,
  87. myspellList: false,
  88. lists: null
  89. })
  90. }
  91. },
  92. //切换拼团列表
  93. getSpellList(){
  94. this.setData({
  95. flag: "spellList",
  96. page:1,
  97. allow_load:true
  98. })
  99. wx.setNavigationBarTitle({
  100. title: '拼团专场'
  101. })
  102. this.getList(1, "spellList")
  103. },
  104. //去使用
  105. gotoUse(e){
  106. console.log(e)
  107. wx.navigateTo({
  108. url: '/pages/couponorder/index/index',
  109. })
  110. },
  111. //重新拼团
  112. gotoAgain(e){
  113. let data = e.currentTarget.dataset.data
  114. wx.navigateTo({
  115. url: `/pages/spellGroup/mySpellGroup/index?couponId=${data.couponId}&couponChannelId=${data.couponChannelId}`,
  116. })
  117. },
  118. //跳转到我的拼团详情
  119. gotoStatusDetail(e){
  120. console.log(e,333)
  121. let data = e.currentTarget.dataset.data
  122. wx.navigateTo({
  123. url: `/pages/spellDetail/index?orderId=${data.orderId}&couponId=${data.couponId}&orderGroupId=${data.orderGroupId}&couponChannelId=${data.couponChannelId}`,
  124. })
  125. },
  126. //切换我的拼团
  127. getmyList(){
  128. this.setData({
  129. flag: "myspellList",
  130. page: 1,
  131. allow_load: true,
  132. lists:null
  133. })
  134. wx.setNavigationBarTitle({
  135. title: '我的拼团'
  136. })
  137. this.getList(1, "myspellList")
  138. },
  139. /**
  140. * banner
  141. */
  142. getBannerlist: function () {
  143. let that = this;
  144. Http.get({
  145. url: config.api.bannerlist,
  146. data: {
  147. pageNum: 1,
  148. pageSize: 7
  149. }
  150. }).then(res => {
  151. that.setData({
  152. list: res.data.list
  153. });
  154. });
  155. },
  156. changeStatus(status){
  157. return spellStatus02.filter(item=>status==item.value)[0].name
  158. },
  159. changeStatus02(status) {
  160. console.log(status)
  161. return spellStatus.filter(item => status == item.value)[0].name
  162. },
  163. gotoPay(e){
  164. this.setData({
  165. reloadIf:true
  166. })
  167. let data = e.currentTarget.dataset.data
  168. wx.navigateTo({
  169. url: `/pages/spellGroup/paySpellGroup/index?orderId=${data.orderId}&couponId=${data.couponId}&orderGroupId=${data.orderGroupId}&couponChannelId=${data.couponChannelId}`,
  170. })
  171. },
  172. gotoEdit(e){
  173. console.log(e.currentTarget.dataset.status)
  174. let status = e.currentTarget.dataset.status
  175. if (status==10){
  176. }
  177. },
  178. getUserInfo: function () {
  179. let that = this;
  180. // 获取用户信息
  181. Http.get({
  182. url: config.api.getScore,
  183. data: {}
  184. })
  185. .then(res => {
  186. console.log(res)
  187. that.setData({
  188. nickName: res.data.nickName,
  189. avatarUrl: res.data.avatarUrl
  190. })
  191. })
  192. },
  193. getList(pageNum, flag) {
  194. var that = this;
  195. console.log(pageNum)
  196. if (that.data.allow_load) {
  197. /**
  198. * myspellList: 我的砍价
  199. * spellList: 砍价商品
  200. */
  201. that.setData({
  202. loading: true,
  203. content: '小主,我在玩命加载中...'
  204. })
  205. var param = {};
  206. if (flag == 'myspellList') {
  207. console.log(22222222)
  208. that.setData({
  209. flag: "myspellList"
  210. })
  211. var param = {
  212. pageNum: pageNum,
  213. pageSize: 10
  214. };
  215. var url = config.api.getMySepllList;
  216. } else if (flag == 'spellList') {
  217. console.log(111111)
  218. that.setData({
  219. flag: "spellList"
  220. })
  221. var param = {
  222. pageNum: pageNum,
  223. pageSize: 10,
  224. targetAd: 7
  225. };
  226. var url = config.api.couponChannelList;
  227. }
  228. // 请求接口
  229. Http.get({
  230. url: url,
  231. data: param
  232. }).then(res => {
  233. console.log(res)
  234. /**
  235. * 加载完成
  236. */
  237. if (pageNum >= res.data.pages) {
  238. if (res.data.pages == 0 || res.data.pages == 1) {
  239. that.setData({
  240. allow_load: true,
  241. loading: false,
  242. content: ""
  243. });
  244. } else {
  245. that.setData({
  246. allow_load: false,
  247. loading: true,
  248. content: "——— 再拉裤子就掉了啦 ———",
  249. });
  250. }
  251. }
  252. if (pageNum == 1) {
  253. that.setData({
  254. lists: [],
  255. })
  256. }
  257. if (flag == 'spellList') {
  258. var tmpArr = that.data.lists;
  259. tmpArr.push.apply(tmpArr, res.data.list);
  260. that.setData({
  261. lists: tmpArr
  262. })
  263. } else if (flag == 'myspellList') {
  264. console.log(res.data.list)
  265. var tmpArr = that.data.lists;
  266. res.data.list.map((item,index)=>{
  267. item.statusText = that.changeStatus(item.orderStatus);
  268. item.statusText02 = that.changeStatus02(item.orderStatus)
  269. })
  270. tmpArr.push.apply(tmpArr, res.data.list);
  271. console.log(tmpArr)
  272. let lists = [];
  273. tmpArr.map(file => {
  274. lists.push(file);
  275. })
  276. that.setData({
  277. lists: lists
  278. })
  279. }
  280. wx.stopPullDownRefresh();
  281. })
  282. .catch(err => {
  283. wx.stopPullDownRefresh();
  284. wx.showToast({
  285. title: err.message,
  286. icon: 'none',
  287. duration: 2000,
  288. mask: false
  289. });
  290. })
  291. setTimeout(function () {
  292. that.setData({
  293. loading: false,
  294. })
  295. }, 1400);
  296. } else {
  297. that.setData({
  298. loading: true,
  299. content: "——— 再拉裤子就掉了啦 ———"
  300. })
  301. setTimeout(function () {
  302. that.setData({
  303. loading: false,
  304. })
  305. }, 1400)
  306. }
  307. },
  308. /**
  309. * 如果是重新砍价,需要重新下单
  310. */
  311. orderSave: function (couponId, couponChannelId) {
  312. Http.post({
  313. url: config.api.orderSave,
  314. data: {
  315. couponId: "" + couponId,
  316. couponChannelId: "" + couponChannelId,
  317. press: true
  318. }
  319. })
  320. .then(res => {
  321. console.log(res)
  322. wx.navigateTo({
  323. url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${res.data.orderNumber}`
  324. })
  325. })
  326. .catch(err => {
  327. wx.showToast({
  328. title: err.message,
  329. icon: "none"
  330. })
  331. })
  332. },
  333. inviteFriend: function (e) {
  334. /**
  335. * 添加标识
  336. */
  337. wx.navigateTo({
  338. url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${e.currentTarget.dataset.id}`
  339. })
  340. },
  341. // barginAgain: function (e) {
  342. // let that = this;
  343. // console.log(e)
  344. // let couponId = e.currentTarget.dataset.couponid;
  345. // let couponChannelId = e.currentTarget.dataset.couponchannelid;
  346. // // let orderId = e.currentTarget.dataset.id;
  347. // that.orderSave(couponId, couponChannelId)
  348. // },
  349. // myspellList: function () {
  350. // let that = this;
  351. // that.setData({
  352. // spellList: false,
  353. // myspellList: true,
  354. // flag: "myspellList",
  355. // allow_load: true,
  356. // loading: false,
  357. // content: "",
  358. // page: 1
  359. // })
  360. // that.getList(1, 'myspellList');
  361. // wx.setNavigationBarTitle({
  362. // title: '我的砍价'
  363. // })
  364. // },
  365. spellList: function () {
  366. let that = this;
  367. that.setData({
  368. spellList: true,
  369. myspellList: false,
  370. flag: "spellList",
  371. allow_load: true,
  372. loading: false,
  373. page: 1,
  374. content: ""
  375. })
  376. that.getList(1, 'spellList');
  377. wx.setNavigationBarTitle({
  378. title: '砍价专场'
  379. })
  380. },
  381. /**
  382. *
  383. * @param goto拼团券详情
  384. */
  385. invite: function (e) {
  386. let couponChannelId = e.currentTarget.dataset.id;
  387. let couponId = e.currentTarget.dataset.couponid;
  388. if (couponChannelId && couponId) {
  389. wx.navigateTo({
  390. url: `/pages/spellGroup/mySpellGroup/index?couponChannelId=${couponChannelId}&couponId=${couponId}`
  391. })
  392. }
  393. },
  394. //加载更多
  395. onReachBottom: function () {
  396. let that = this;
  397. that.data.page++;
  398. that.setData({
  399. page: that.data.page
  400. });
  401. that.getList(that.data.page, that.data.flag);
  402. },
  403. /**
  404. * 刷新
  405. */
  406. onPullDownRefresh: function (e) {
  407. let that = this;
  408. if (that.data.flag == 'spellList') {
  409. that.getBannerlist();
  410. var todayDate = new Date().getTime();
  411. that.setData({
  412. todayDate: todayDate
  413. })
  414. that.getList(1, "spellList");
  415. that.setData({
  416. flag: "spellList",
  417. spellList: true,
  418. myspellList: false
  419. })
  420. } else if (that.data.flag == 'myspellList') {
  421. that.getList(1, "myspellList");
  422. that.setData({
  423. flag: "myspellList",
  424. spellList: false,
  425. myspellList: true
  426. })
  427. }
  428. },
  429. })