抖音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.

374 lines
9.0 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. Http.get({
  93. url: '/mall/subMall?isAll=1',
  94. }).then(res => {
  95. this.setData({
  96. shopList: res.data,
  97. // tt.getStorageSync('mallTenantId') ||
  98. mallTenantId: res.data[0].tenantId
  99. });
  100. console.log(this.data.shopList, 'list');
  101. }).catch(err => {
  102. console.log(err, 'err');
  103. })
  104. },
  105. onShow() {
  106. this.getList(this.data.boatFlag, 1);
  107. Http.get({
  108. url: config.api.checkUserStatus,
  109. data: {
  110. token: app.globalData.token
  111. }
  112. }).then(res => {
  113. Http.get({
  114. url: config.api.checkPhoneStatus
  115. }).then(res => {}).catch(err => {
  116. if (app.globalData.ifCongPh == 1) {
  117. app.globalData.skip = 'navigateBack'
  118. tt.navigateTo({
  119. url: `/pages/getPhone/getPhone?skipUrl=1`,
  120. })
  121. } else {
  122. this.setData({
  123. showBox: true
  124. })
  125. }
  126. })
  127. }).catch(err => {
  128. if (err.code == 11004) { //未授权抖音
  129. app.globalData.type = 'mo'
  130. tt.navigateTo({
  131. url: '/pages/getuserinfo/getuserinfo',
  132. });
  133. }
  134. })
  135. this.setData({
  136. ifshowtab: app.globalData.ifshowtab,
  137. allow_load: true
  138. })
  139. },
  140. /**
  141. * 砍价中的状态
  142. * 跳转到砍价详情页面
  143. */
  144. gotoDiscount: function (e) {
  145. tt.navigateTo({
  146. url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${e.currentTarget.dataset.id}`
  147. })
  148. },
  149. cancel(e) { //取消订单
  150. tt.showModal({
  151. title: '提示',
  152. content: '您是否要取消该订单',
  153. confirmText: "确定",
  154. success: (res) => {
  155. if (res.confirm) {
  156. Http.post({
  157. url: config.api.orderCancel,
  158. data: {
  159. orderId: e.currentTarget.dataset.id
  160. }
  161. }).then(res => {
  162. this.getList(this.data.boatFlag, 1);
  163. tt.showToast({
  164. title: "取消订单成功!",
  165. icon: 'none',
  166. duration: 2000,
  167. mask: false
  168. });
  169. }).catch(err => {
  170. tt.showToast({
  171. title: err.message ? err.message : err.data,
  172. icon: 'none',
  173. duration: 2000,
  174. mask: false
  175. });
  176. })
  177. } else if (res.cancel) {
  178. console.log("取消");
  179. }
  180. },
  181. fail(err) {
  182. console.log(`showModal 调用失败`, err);
  183. },
  184. });
  185. },
  186. gotopay: function (e) {
  187. let level = e.currentTarget.dataset.level
  188. if (level == 0) {
  189. tt.navigateTo({
  190. url: `/pages/order/detail/index?orderId=${e.currentTarget.dataset.id}&mallTenantId=${this.data.mallTenantId}&flag='pay'`
  191. })
  192. } else {
  193. tt.navigateTo({
  194. url: `/pages/order/detail/index?orderId=${e.currentTarget.dataset.id}&mallTenantId=${this.data.mallTenantId}&dingdan=order&flag='pay'`
  195. })
  196. }
  197. },
  198. //再次购买
  199. gotopayAgain: function (e) {
  200. tt.navigateTo({
  201. url: `/pages/coupon/detail/index?couponChannelId=${e.currentTarget.dataset.couponchannelid
  202. }&couponId=${e.currentTarget.dataset.couponid}`
  203. });
  204. },
  205. // gotoSpellPay(e) {
  206. // console.log(e, 333)
  207. // let data = e.currentTarget.dataset.data
  208. // tt.navigateTo({
  209. // url: `/pages/spellGroup/paySpellGroup/index?orderId=${data.orderId}&couponId=${data.couponId}&orderGroupId=${data.orderGroupId}&couponChannelId=${data.couponChannelId}`,
  210. // })
  211. // },
  212. getList(key, pageNum) {
  213. let that = this;
  214. if (key == undefined) {
  215. key = 'all'
  216. }
  217. /**
  218. * key==0
  219. * 不发送该字段
  220. */
  221. // const mallTenantId = tt.getStorageSync('mallTenantId')
  222. if (key == 'all') {
  223. var variable = {
  224. pageNum: pageNum,
  225. pageSize: 10,
  226. paymentType: 0,
  227. mallTenantId: that.data.mallTenantId
  228. };
  229. } else {
  230. var variable = {
  231. pageNum: pageNum,
  232. pageSize: 10,
  233. orderStatus: key,
  234. paymentType: 0,
  235. mallTenantId: that.data.mallTenantId
  236. };
  237. }
  238. if (that.data.allow_load) {
  239. that.setData({
  240. loading: true,
  241. content: '小主,我在玩命加载中...'
  242. })
  243. Http.get({
  244. url: config.api.orderList,
  245. data: variable
  246. }).then(res => {
  247. if (pageNum >= res.data.pages) {
  248. that.setData({
  249. allow_load: false
  250. });
  251. setTimeout(function () {
  252. that.setData({
  253. loading: false,
  254. })
  255. }, 1400);
  256. }
  257. setTimeout(function () {
  258. that.setData({
  259. loading: false,
  260. })
  261. }, 1400);
  262. if (pageNum == 1) {
  263. that.setData({
  264. list: []
  265. })
  266. }
  267. var tmpArr = that.data.list;
  268. tmpArr.push.apply(tmpArr, res.data.list);
  269. // 将砍价的状态过滤出来
  270. console.log(tmpArr)
  271. tmpArr.map(item => {
  272. item.orders.map(itemChild => {
  273. itemChild.createDate = util.formatTime(itemChild.createDate, "yyyy-MM-dd hh:mm:ss");
  274. })
  275. })
  276. that.setData({
  277. list: tmpArr
  278. })
  279. for (let i = 0; i < that.data.list.length; i++) {
  280. var createDate1 = util.formatTime(that.data.list[i].createDate, "yyyy-MM-dd hh:mm:ss");
  281. /**
  282. * 修改list的endtime
  283. * 渲染到页面
  284. */
  285. var createDate = 'list[' + i + '].createDate'
  286. that.setData({
  287. [createDate]: createDate1
  288. });
  289. }
  290. })
  291. .catch(err => {
  292. tt.showModal({
  293. title: '提示',
  294. content: err.message ? err.message : err.data,
  295. showCancel: false
  296. })
  297. })
  298. } else {
  299. that.setData({
  300. loading: true,
  301. content: "——— 再拉裤子就掉了啦 ———"
  302. })
  303. setTimeout(function () {
  304. that.setData({
  305. loading: false,
  306. })
  307. }, 1400)
  308. }
  309. },
  310. handleChange({
  311. detail
  312. }) {
  313. this.setData({
  314. current: detail.key
  315. });
  316. },
  317. setBoatFlag(e) {
  318. if (app.globalData.ifCongPh == 1) {
  319. let index = e.currentTarget.dataset.index
  320. console.log(index);
  321. this.setData({
  322. boatFlag: index,
  323. pageNum: 1,
  324. allow_load: true,
  325. })
  326. this.getList(index, 1)
  327. } else {
  328. this.setData({
  329. showBox: true
  330. })
  331. }
  332. },
  333. // handleChangeScroll({
  334. // detail
  335. // }) {
  336. // this.setData({
  337. // list: [],
  338. // allow_load: true,
  339. // current_scroll: detail.key,
  340. // page: 1
  341. // })
  342. // this.getList(detail.key, 1);
  343. // },
  344. onReachBottom: function () {
  345. var that = this;
  346. that.data.page++;
  347. that.setData({
  348. page: that.data.page
  349. });
  350. that.getList(that.data.boatFlag, that.data.page);
  351. },
  352. });