抖音c端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

380 lines
9.1 KiB

  1. const navigationBarHeight = (getApp().statusBarHeight + 50) + 'px'
  2. let config = require("../../../config/config.js");
  3. let Http = require("../../../utils/HttpBasics");
  4. const util = require("../../../utils/util");
  5. let app = getApp();
  6. const imgurl = require("../../../utils/imgurl");
  7. Page({
  8. data: {
  9. showBox: false, //显示授权手机框
  10. navigationBarHeight,
  11. noOrdersUrl: imgurl.noOrders.url,
  12. loadingUrl: imgurl.loading.url,
  13. wmhome: imgurl.wmhome.url,
  14. wmdiscount: imgurl.wmdiscount.url,
  15. wmgive: imgurl.wmgive.url,
  16. boatFlag: "all",
  17. tabs: [{
  18. key: "all",
  19. name: "全部"
  20. },
  21. {
  22. key: 0,
  23. name: "待付款"
  24. },
  25. {
  26. key: 1,
  27. name: "已完成"
  28. },
  29. {
  30. key: 3,
  31. name: "售后"
  32. }
  33. ],
  34. list: [],
  35. current: "",
  36. loading: true, //"上拉加载"的变量,默认false,隐藏
  37. // current_scroll: "1",
  38. allow_load: true,
  39. page: 1,
  40. content: "",
  41. canIUse: tt.canIUse("button.open-type.getPhoneNumber"), //判断小程序是否能用获取手机插件
  42. ifshowtab: null,
  43. shopList: [],
  44. index: 0,
  45. mallTenantId: ''
  46. },
  47. setPhone(paramData) { //子组件调用这个方法说明手机号已经授权成功
  48. this.setData({
  49. showBox: paramData.detail,
  50. })
  51. this.getList('all', 1)
  52. tt.showToast({
  53. title: '授权成功', // 内容
  54. icon: 'none', // 图标
  55. success: (res) => {},
  56. fail: (res) => {
  57. },
  58. });
  59. },
  60. setBox(paramData) {
  61. this.setData({
  62. showBox: paramData.detail,
  63. })
  64. tt.showToast({
  65. title: '取消授权', // 内容
  66. icon: 'none', // 图标
  67. success: (res) => {
  68. },
  69. fail: (res) => {
  70. },
  71. });
  72. },
  73. bindPickerChange(e) {
  74. const index = e.detail.value
  75. const mallTenantId = this.data.shopList[index].tenantId
  76. // tt.setStorageSync('mallTenantId', mallTenantId)
  77. // tt.setStorageSync('mallIndex', index)
  78. this.setData({
  79. index: index,
  80. mallTenantId: mallTenantId,
  81. allow_load: true
  82. });
  83. console.log(this.data.mallTenantId);
  84. this.getList(this.data.boatFlag, 1);
  85. },
  86. goback: function () {
  87. tt.reLaunch({
  88. url: '/index/index',
  89. })
  90. },
  91. onLoad(e) {
  92. // this.setData({
  93. // current_scroll: e.id
  94. // });
  95. this.setData({
  96. // tt.getStorageSync('mallIndex') ||
  97. index: 0,
  98. })
  99. },
  100. onShow() {
  101. Http.get({
  102. url: '/mall/subMall?isAll=1',
  103. }).then(res => {
  104. this.setData({
  105. shopList: res.data,
  106. mallTenantId: tt.getStorageSync('mallTenantId') || res.data[0].tenantId
  107. });
  108. this.getList(this.data.boatFlag, 1);
  109. Http.get({
  110. url: config.api.checkUserStatus,
  111. data: {
  112. token: app.globalData.token
  113. }
  114. }).then(res => {
  115. Http.get({
  116. url: config.api.checkPhoneStatus
  117. }).then(res => {}).catch(err => {
  118. if (app.globalData.ifCongPh == 1) {
  119. app.globalData.skip = 'navigateBack'
  120. tt.navigateTo({
  121. url: `/pages/getPhone/getPhone?skipUrl=1`,
  122. })
  123. } else {
  124. this.setData({
  125. showBox: true
  126. })
  127. }
  128. })
  129. }).catch(err => {
  130. if (err.code == 11004) { //未授权抖音
  131. app.globalData.type = 'mo'
  132. tt.navigateTo({
  133. url: '/pages/getuserinfo/getuserinfo',
  134. });
  135. }
  136. })
  137. }).catch(err => {
  138. })
  139. this.setData({
  140. ifshowtab: app.globalData.ifshowtab,
  141. allow_load: true
  142. })
  143. },
  144. /**
  145. * 砍价中的状态
  146. * 跳转到砍价详情页面
  147. */
  148. gotoDiscount: function (e) {
  149. tt.navigateTo({
  150. url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${e.currentTarget.dataset.id}`
  151. })
  152. },
  153. cancel(e) { //取消订单
  154. tt.showModal({
  155. title: '提示',
  156. content: '您是否要取消该订单',
  157. confirmText: "确定",
  158. success: (res) => {
  159. if (res.confirm) {
  160. Http.post({
  161. url: config.api.orderCancel,
  162. data: {
  163. orderId: e.currentTarget.dataset.id
  164. }
  165. }).then(res => {
  166. this.getList(this.data.boatFlag, 1);
  167. tt.showToast({
  168. title: "取消订单成功!",
  169. icon: 'none',
  170. duration: 2000,
  171. mask: false
  172. });
  173. }).catch(err => {
  174. tt.showToast({
  175. title: err.message ? err.message : err.data,
  176. icon: 'none',
  177. duration: 2000,
  178. mask: false
  179. });
  180. })
  181. } else if (res.cancel) {
  182. console.log("取消");
  183. }
  184. },
  185. fail(err) {
  186. console.log(`showModal 调用失败`, err);
  187. },
  188. });
  189. },
  190. gotopay: function (e) {
  191. let level = e.currentTarget.dataset.level
  192. if (level == 0) {
  193. tt.navigateTo({
  194. url: `/pages/order/detail/index?orderId=${e.currentTarget.dataset.id}&mallTenantId=${this.data.mallTenantId}&flag='pay'`
  195. })
  196. } else {
  197. tt.navigateTo({
  198. url: `/pages/order/detail/index?orderId=${e.currentTarget.dataset.id}&mallTenantId=${this.data.mallTenantId}&dingdan=order&flag='pay'`
  199. })
  200. }
  201. },
  202. //再次购买
  203. gotopayAgain: function (e) {
  204. tt.navigateTo({
  205. url: `/pages/coupon/detail/index?couponChannelId=${e.currentTarget.dataset.couponchannelid
  206. }&couponId=${e.currentTarget.dataset.couponid}`
  207. });
  208. },
  209. // gotoSpellPay(e) {
  210. // console.log(e, 333)
  211. // let data = e.currentTarget.dataset.data
  212. // tt.navigateTo({
  213. // url: `/pages/spellGroup/paySpellGroup/index?orderId=${data.orderId}&couponId=${data.couponId}&orderGroupId=${data.orderGroupId}&couponChannelId=${data.couponChannelId}`,
  214. // })
  215. // },
  216. getList(key, pageNum) {
  217. let that = this;
  218. if (key == undefined) {
  219. key = 'all'
  220. }
  221. /**
  222. * key==0
  223. * 不发送该字段
  224. */
  225. // const mallTenantId = tt.getStorageSync('mallTenantId')
  226. if (key == 'all') {
  227. var variable = {
  228. pageNum: pageNum,
  229. pageSize: 10,
  230. paymentType: 0,
  231. mallTenantId: that.data.mallTenantId
  232. };
  233. } else {
  234. var variable = {
  235. pageNum: pageNum,
  236. pageSize: 10,
  237. orderStatus: key,
  238. paymentType: 0,
  239. mallTenantId: that.data.mallTenantId
  240. };
  241. }
  242. if (that.data.allow_load) {
  243. that.setData({
  244. loading: true,
  245. content: '小主,我在玩命加载中...'
  246. })
  247. Http.get({
  248. url: config.api.orderList,
  249. data: variable
  250. }).then(res => {
  251. if (pageNum >= res.data.pages) {
  252. that.setData({
  253. allow_load: false
  254. });
  255. setTimeout(function () {
  256. that.setData({
  257. loading: false,
  258. })
  259. }, 1400);
  260. }
  261. setTimeout(function () {
  262. that.setData({
  263. loading: false,
  264. })
  265. }, 1400);
  266. if (pageNum == 1) {
  267. that.setData({
  268. list: []
  269. })
  270. }
  271. var tmpArr = that.data.list;
  272. tmpArr.push.apply(tmpArr, res.data.list);
  273. // 将砍价的状态过滤出来
  274. console.log(tmpArr)
  275. tmpArr.map(item => {
  276. item.orders.map(itemChild => {
  277. itemChild.createDate = util.formatTime(itemChild.createDate, "yyyy-MM-dd hh:mm:ss");
  278. })
  279. })
  280. that.setData({
  281. list: tmpArr
  282. })
  283. for (let i = 0; i < that.data.list.length; i++) {
  284. var createDate1 = util.formatTime(that.data.list[i].createDate, "yyyy-MM-dd hh:mm:ss");
  285. /**
  286. * 修改list的endtime
  287. * 渲染到页面
  288. */
  289. var createDate = 'list[' + i + '].createDate'
  290. that.setData({
  291. [createDate]: createDate1
  292. });
  293. }
  294. })
  295. .catch(err => {
  296. tt.showModal({
  297. title: '提示',
  298. content: err.message ? err.message : err.data,
  299. showCancel: false
  300. })
  301. })
  302. } else {
  303. that.setData({
  304. loading: true,
  305. content: "——— 再拉裤子就掉了啦 ———"
  306. })
  307. setTimeout(function () {
  308. that.setData({
  309. loading: false,
  310. })
  311. }, 1400)
  312. }
  313. },
  314. handleChange({
  315. detail
  316. }) {
  317. this.setData({
  318. current: detail.key
  319. });
  320. },
  321. setBoatFlag(e) {
  322. if (app.globalData.ifCongPh == 1) {
  323. let index = e.currentTarget.dataset.index
  324. console.log(index);
  325. this.setData({
  326. boatFlag: index,
  327. pageNum: 1,
  328. allow_load: true,
  329. })
  330. this.getList(index, 1)
  331. } else {
  332. this.setData({
  333. showBox: true
  334. })
  335. }
  336. },
  337. // handleChangeScroll({
  338. // detail
  339. // }) {
  340. // this.setData({
  341. // list: [],
  342. // allow_load: true,
  343. // current_scroll: detail.key,
  344. // page: 1
  345. // })
  346. // this.getList(detail.key, 1);
  347. // },
  348. onReachBottom: function () {
  349. var that = this;
  350. that.data.page++;
  351. that.setData({
  352. page: that.data.page
  353. });
  354. that.getList(that.data.boatFlag, that.data.page);
  355. },
  356. });