抖音c端
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

liveLsit.js 6.2 KiB

2 år sedan
2 år sedan
2 år sedan
2 år sedan
1 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
1 år sedan
2 år sedan
1 år sedan
2 år sedan
2 år sedan
2 år sedan
1 år sedan
2 år sedan
1 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
1 år sedan
2 år sedan
1 år sedan
2 år sedan
1 år sedan
2 år sedan
1 år sedan
2 år sedan
2 år sedan
2 år sedan
1 år sedan
2 år sedan
2 år sedan
2 år sedan
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. const navigationBarHeight = (getApp().statusBarHeight + 44) + 'px'
  2. const util = require("../../utils/util.js");
  3. const Http = require("../../utils/HttpBasics");
  4. const config = require("../../config/config");
  5. const imgurl = require("../../utils/imgurl");
  6. const {
  7. alipay
  8. } = require("../../utils/imgurl");
  9. let app = getApp();
  10. Page({
  11. data: {
  12. navLineHeight: ((app.statusBarHeight + app.statusBarHeight) + 50) + "px",
  13. navigationBarHeight,
  14. noDataFlag: false,
  15. businePageNum: 1,
  16. businessData: null,
  17. Lsit: [],
  18. mallTenantId: '',
  19. },
  20. goOrder() {
  21. tt.navigateTo({
  22. url: '/pages/order/index/index',
  23. success: (res) => {
  24. },
  25. fail: (res) => {
  26. },
  27. });
  28. },
  29. getCouponChannelList(key) {
  30. if (app.globalData.token) {
  31. if (this.data.noDataFlag) {
  32. return
  33. }
  34. tt.showLoading({
  35. title: "加载中"
  36. });
  37. let param = {}
  38. if (key == 0) {
  39. param = {
  40. pageNum: this.data.businePageNum,
  41. pageSize: 6,
  42. targetAd: 101,
  43. mallTenantId: this.data.mallTenantId
  44. }
  45. } else {
  46. param = {
  47. pageNum: this.data.businePageNum,
  48. pageSize: 6,
  49. business: key,
  50. targetAd: 101,
  51. mallTenantId: this.data.mallTenantId
  52. }
  53. }
  54. Http.get({
  55. url: config.api.couponChannelDouyinLiveList,
  56. data: param
  57. }).then(res => {
  58. if (res.data.list && res.data.list.length != 0) {
  59. let tempArr = []
  60. let tempLsit = this.data.businessData
  61. let data = res.data.list
  62. data.map(item => {
  63. tempArr.push(item.id)
  64. item.discount = (((item.salePriceStr * 1) / (item.priceStr * 1)) * 10).toFixed(1)
  65. })
  66. if (this.data.businePageNum > 1) {
  67. this.setData({
  68. businessData: [...tempLsit, ...data]
  69. })
  70. } else {
  71. this.setData({
  72. businessData: data
  73. })
  74. }
  75. this.getPriceAndStock(tempArr.join())
  76. } else {
  77. this.setData({
  78. noDataFlag: true
  79. })
  80. }
  81. tt.hideLoading();
  82. }).catch(err => {
  83. tt.hideLoading();
  84. tt.showModal({
  85. title: '提示',
  86. content: err.message ? err.message : err.data,
  87. showCancel: false
  88. })
  89. })
  90. } else {
  91. app.tokenCallback = token => {
  92. if (this.data.noDataFlag) {
  93. return
  94. }
  95. tt.showLoading({
  96. title: "加载中"
  97. });
  98. let param = {}
  99. if (key == 0) {
  100. param = {
  101. pageNum: this.data.businePageNum,
  102. pageSize: 6,
  103. targetAd: 101,
  104. mallTenantId: this.data.mallTenantId
  105. }
  106. } else {
  107. param = {
  108. pageNum: this.data.businePageNum,
  109. pageSize: 6,
  110. business: key,
  111. targetAd: 101,
  112. mallTenantId: this.data.mallTenantId
  113. }
  114. }
  115. Http.get({
  116. url: config.api.couponChannelDouyinLiveList,
  117. data: param
  118. }).then(res => {
  119. if (res.data.list && res.data.list.length != 0) {
  120. let tempArr = []
  121. let tempLsit = this.data.businessData
  122. let data = res.data.list
  123. data.map(item => {
  124. tempArr.push(item.id)
  125. item.discount = (((item.salePriceStr * 1) / (item.priceStr * 1)) * 10).toFixed(1)
  126. })
  127. if (this.data.businePageNum > 1) {
  128. this.setData({
  129. businessData: [...tempLsit, ...data]
  130. })
  131. } else {
  132. this.setData({
  133. businessData: data
  134. })
  135. }
  136. this.getPriceAndStock(tempArr.join())
  137. } else {
  138. this.setData({
  139. noDataFlag: true
  140. })
  141. }
  142. tt.hideLoading();
  143. }).catch(err => {
  144. tt.hideLoading();
  145. tt.showModal({
  146. title: '提示',
  147. content: err.message ? err.message : err.data,
  148. showCancel: false
  149. })
  150. })
  151. }
  152. }
  153. },
  154. upDataLsit() {
  155. this.setData({
  156. businePageNum: 1,
  157. noDataFlag: false,
  158. businessData: []
  159. });
  160. this.getCouponChannelList(0)
  161. },
  162. //获取券列表的价格和库存(列表接口有缓存通过这个来获取) str 列表数组里面的所有id
  163. getPriceAndStock(str) {
  164. console.log(str);
  165. Http.get({
  166. url: config.api.batchCouponPriceAndStock,
  167. data: {
  168. couponChannelIds: str,
  169. mallTenantId: this.data.mallTenantId
  170. }
  171. }).then(res => {
  172. console.log(JSON.parse(res.data));
  173. let tempObj = JSON.parse(res.data)
  174. let tempData = this.data.businessData
  175. tempData.map(item1 => {
  176. tempObj.map(item2 => {
  177. if (item2.id == item1.id) {
  178. item1.sale = item2.inventory - item2.remainInventory
  179. item1.percent = ((item1.sale / item2.inventory).toFixed(3)) * 100 + '%'
  180. item1.salePriceStr = item2.salePrice / 100
  181. item1.priceStr = item2.price / 100
  182. }
  183. })
  184. })
  185. this.setData({
  186. Lsit: tempData
  187. })
  188. }).catch(err => {
  189. tt.hideLoading();
  190. tt.showModal({
  191. title: '提示',
  192. content: err.message ? err.message : err.data,
  193. showCancel: false
  194. })
  195. })
  196. },
  197. goDetail(e) {
  198. console.log(e, 'e');
  199. let couponChannelId = e.currentTarget.dataset.id
  200. let couponId = e.currentTarget.dataset.couponid
  201. let mallTenantId = this.data.mallTenantId
  202. tt.navigateTo({
  203. url: `/pages/coupon/detail/index?couponChannelId=${couponChannelId}&couponId=${couponId}&mallTenantId=${mallTenantId}`,
  204. })
  205. },
  206. onLoad: function (options) {
  207. //固定写法 放在指定要手机号授权框出现
  208. // app.globalData.ifCongPh = 1
  209. this.getCouponChannelList()
  210. tt.setStorageSync('mallTenantId', options.tenantId);
  211. this.setData({
  212. mallTenantId: options.tenantId
  213. })
  214. },
  215. onReachBottom: function () {
  216. console.log("我到底了")
  217. let that = this;
  218. that.setData({
  219. businePageNum: that.data.businePageNum + 1
  220. });
  221. console.log("加载更多页数" + that.data.page, );
  222. console.log("加载更多key" + that.data.code);
  223. this.getCouponChannelList(0)
  224. },
  225. })