wholesale.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. <template>
  2. <view class="content">
  3. <image src="../../static/img/wh-bg.png" mode="" class="to-bg"></image>
  4. <view class="top-tit">
  5. {{gooditem.state}}
  6. </view>
  7. <view class="top-time" v-if="gooditem.time">
  8. {{gooditem.time + ' ' + '~' + ' '}}{{gooditem.stop | time}}
  9. </view>
  10. <view class="center-btn flex" @click="navto('/pages/user/myWholesale')">
  11. <image src="../../static/icon/pf-logo.png" mode="" class="center-logo"></image>
  12. <view class="center-tit">
  13. <view class="tit-top">
  14. 批发订单
  15. </view>
  16. <view class="">
  17. 查看我购买的批发订单
  18. </view>
  19. </view>
  20. <image src="../../static/img/img74.png" mode="" class="look-more"></image>
  21. </view>
  22. <scroll-view scroll-y="true" class="swiper-box" :style="{'height': height}" @scrolltolower="getWholeList()">
  23. <view class="good-wrap">
  24. <template v-if="userInfo && userInfo.is_whole == 0">
  25. <!-- <template> -->
  26. <view class="good" v-for="itemt in newlist" @click="navto('/pages/product/wholesaleDetail?id=' + itemt.id + '&time=' + itemt.time_id + '&status=' + itemt.status + '&is_new=' + is_new)">
  27. <image :src="itemt.image" mode="" class="goo-img"></image>
  28. <view class="xrlb">
  29. 新人礼包
  30. </view>
  31. <view class="good-tit clamp">
  32. {{itemt.title}}
  33. </view>
  34. <view class="good-price flex">
  35. <view class="new-price">
  36. ¥{{itemt.price}}
  37. </view>
  38. </view>
  39. </view>
  40. </template>
  41. <view class="good" v-for="item in list" @click="gotoDetail(item)">
  42. <image :src="item.whole.image" mode="" class="goo-img"></image>
  43. <view class="good-tit clamp">
  44. {{item.whole.title}}
  45. </view>
  46. <view class="good-price flex">
  47. <view class="new-price">
  48. ¥{{item.price}}
  49. </view>
  50. <!-- <view class="old-price">
  51. ¥{{item.}}
  52. </view> -->
  53. </view>
  54. </view>
  55. </view>
  56. <uni-load-more :status="loadingType"></uni-load-more>
  57. </scroll-view>
  58. </view>
  59. </template>
  60. <script>
  61. import {
  62. mapState,
  63. mapMutations
  64. } from 'vuex';
  65. import {
  66. timeComputed
  67. } from '@/utils/rocessor.js'
  68. import {
  69. getWholeList,
  70. getNewList,
  71. getWholeTimeArea,
  72. } from '@/api/whole.js'
  73. import {
  74. getUserInfo
  75. } from '@/api/user.js'
  76. import uniCountdown from '@/components/uni-countdown/uni-countdown.vue';
  77. import empty from '@/components/empty';
  78. export default {
  79. components: {
  80. empty,
  81. uniCountdown
  82. },
  83. data() {
  84. return {
  85. newlist: [],
  86. height: '',
  87. list: [],
  88. page: 1,
  89. limit: 10,
  90. loadingType: 'more',
  91. loaded: false,
  92. bin: '',
  93. stop: '',
  94. status: '',
  95. state: '',
  96. stopTimeH: '',
  97. stopTimeM: '',
  98. stopTimeS: '',
  99. timer: '',
  100. wid: '',
  101. time_id: 0,
  102. gooditem: {},
  103. is_new: 'non',
  104. userInfo: {}
  105. }
  106. },
  107. onReady(res) {
  108. var obj = this;
  109. uni.getSystemInfo({
  110. success: resu => {
  111. const query = uni.createSelectorQuery();
  112. query.select('.swiper-box').boundingClientRect();
  113. query.exec(function(res) {
  114. obj.height = resu.windowHeight - res[0].top + 'px';
  115. console.log('打印页面的剩余高度', obj.height);
  116. });
  117. },
  118. fail: res => {}
  119. });
  120. },
  121. onLoad(opt) {
  122. let obj = this
  123. obj.bin = decodeURI(opt.bin)
  124. obj.stop = opt.stp
  125. obj.status = opt.status
  126. obj.state = opt.state
  127. obj.wid = opt.wid
  128. obj.getNewList()
  129. console.log(obj.bin, obj.stop, obj.status)
  130. },
  131. onShow() {
  132. let obj = this
  133. obj.getUserInfo()
  134. obj.getTimeArea()
  135. },
  136. filters: {
  137. time(val) {
  138. let str = ''
  139. if(val) {
  140. let date = new Date(val*1000)
  141. let m = date.getHours() > 9 ? date.getHours() : ( '0'+ date.getHours())
  142. let s = date.getMinutes() > 9 ? date.getMinutes() : ( '0'+ date.getMinutes())
  143. str = m + ':' + s
  144. }
  145. return str
  146. }
  147. },
  148. methods: {
  149. ...mapMutations('user', ['setUserInfo', 'setOrderInfo']),
  150. getUserInfo() {
  151. getUserInfo().then(res => {
  152. console.log(res)
  153. this.setUserInfo(res.data);
  154. this.userInfo = res.data
  155. this.is_new = res.data.is_whole == 0? 'isn': 'non'
  156. })
  157. },
  158. getTimeArea() {
  159. let obj = this
  160. getWholeTimeArea().then(({
  161. data
  162. }) => {
  163. // this.list = data.seckillTime
  164. console.log(data.seckillTime[0])
  165. data.seckillTime.forEach(item => {
  166. if(obj.wid == item.id) {
  167. obj.gooditem = item
  168. }
  169. })
  170. // this.gooditem = data.seckillTime[0]
  171. // this.wid = this.gooditem.id
  172. console.log('时间获取成功',this.gooditem.id)
  173. this.getWholeList()
  174. // this.list.forEach(item => {
  175. // })
  176. })
  177. },
  178. getNewList() {
  179. getNewList({
  180. page: 1,
  181. limit: 100
  182. }).then(res => {
  183. console.log(res, 'getNewList')
  184. this.newlist = res.data
  185. })
  186. },
  187. gotoDetail(item) {
  188. let obj = this
  189. obj.navto('/pages/product/realyWhole?id=' + item.id + '&time=' + item.time_id)
  190. },
  191. navto(url) {
  192. uni.navigateTo({
  193. url: url
  194. })
  195. },
  196. // // 获取剩余时间
  197. // getSyTime() {
  198. // let obj = this
  199. // let stopTime = timeComputed(obj.stop * 1000)
  200. // console.log(stopTime, 'stopTime')
  201. // obj.stopTimeH = stopTime.hours
  202. // obj.stopTimeM = stopTime.minutes >= 10 ? stopTime.minutes : ('0' + stopTime.minutes)
  203. // obj.stopTimeS = stopTime.seconds >= 10 ? stopTime.seconds : ('0' + stopTime.seconds)
  204. // if (stopTime.hours == 0 && stopTime.minutes == 0 && stopTime.seconds == 0) {
  205. // obj.status = 0
  206. // }
  207. // if (!obj.timer) {
  208. // if (obj.status == 1) {
  209. // obj.timer = setTimeout(this.getSyTime, 1000)
  210. // }
  211. // } else {
  212. // clearTimeout(obj.timer)
  213. // if (obj.status == 1) {
  214. // obj.timer = setTimeout(this.getSyTime, 1000)
  215. // }
  216. // }
  217. // // console.log(obj.stopTimeH + ':' + obj.stopTimeM + ':' + obj.stopTimeS)
  218. // },
  219. getWholeList() {
  220. let obj = this
  221. console.log('开始加载')
  222. // obj.loadingType == 'loading'
  223. if(obj.loadingType == 'noMore' || obj.loadingType == 'loading') {
  224. return
  225. }
  226. obj.loadingType = 'loading'
  227. getWholeList({
  228. page: obj.page,
  229. limit: obj.limit
  230. }, obj.wid).then(({
  231. data
  232. }) => {
  233. console.log('结束')
  234. obj.list = obj.list.concat(data.data)
  235. obj.page++
  236. if(data.data.length == obj.limit) {
  237. obj.loadingType = 'more'
  238. }else {
  239. obj.loadingType = 'noMore'
  240. }
  241. })
  242. },
  243. loadmore() {
  244. console.log('加载更多')
  245. }
  246. }
  247. }
  248. </script>
  249. <style lang="scss">
  250. .to-bg {
  251. width: 750rpx;
  252. height: 427rpx;
  253. background-color: #fff;
  254. }
  255. .top-tit {
  256. position: absolute;
  257. top: 170rpx;
  258. left: 0;
  259. right: 0;
  260. margin: auto;
  261. text-align: center;
  262. font-size: 30rpx;
  263. font-family: PingFang SC;
  264. font-weight: 500;
  265. color: #FFFFFF;
  266. }
  267. .top-time {
  268. position: absolute;
  269. top: 240rpx;
  270. left: 0;
  271. right: 0;
  272. margin: auto;
  273. font-size: 83rpx;
  274. text-align: center;
  275. font-family: PingFang SC;
  276. font-weight: bold;
  277. color: #FFFFFF;
  278. }
  279. .center-btn {
  280. padding: 20rpx 32rpx;
  281. background-color: #fff;
  282. margin-bottom: 20rpx;
  283. .center-logo {
  284. width: 83rpx;
  285. height: 106rpx;
  286. flex-shrink: 0;
  287. background-color: #eee;
  288. }
  289. .center-tit {
  290. padding-left: 30rpx;
  291. flex-grow: 1;
  292. font-size: 24rpx;
  293. font-family: PingFang SC;
  294. font-weight: 500;
  295. color: #999999;
  296. line-height: 1.5;
  297. .tit-top {
  298. font-size: 32rpx;
  299. font-family: PingFang SC;
  300. font-weight: bold;
  301. color: #333333;
  302. }
  303. }
  304. .look-more {
  305. width: 16rpx;
  306. height: 30rpx;
  307. flex-shrink: 0;
  308. }
  309. }
  310. .swiper-box {
  311. // background-color: red;
  312. // position: relative;
  313. }
  314. .good-wrap {
  315. display: flex;
  316. // padding: 0 0 20rpx 20rpx;
  317. padding-left: 20rpx;
  318. flex-wrap: wrap;
  319. }
  320. .good {
  321. width: 345rpx;
  322. height: 480rpx;
  323. margin-right: 20rpx;
  324. margin-bottom: 20rpx;
  325. background: #FFFFFF;
  326. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  327. border-radius: 10rpx;
  328. position: relative;
  329. .xrlb {
  330. position: absolute;
  331. display: inline-block;
  332. padding: 5rpx 10rpx;
  333. background-color: #FF4C4C;
  334. color: #fff;
  335. text-align: center;
  336. border-radius: 0 10rpx 10rpx 0;
  337. // width: 100rpx;
  338. top: 0;
  339. left: 0;
  340. }
  341. .goo-img {
  342. width: 345rpx;
  343. height: 345rpx;
  344. border-radius: 10rpx 10rpx 0 0;
  345. // background-color: #bfa;
  346. }
  347. .good-tit {
  348. padding: 15rpx 20rpx;
  349. font-size: 30rpx;
  350. font-family: PingFang SC;
  351. font-weight: bold;
  352. color: #333333;
  353. line-height: 35rpx;
  354. }
  355. .good-price {
  356. padding-left: 20rpx;
  357. justify-content: flex-start;
  358. .new-price {
  359. font-size: 36rpx;
  360. font-family: PingFang SC;
  361. font-weight: bold;
  362. color: #FF4C4C;
  363. }
  364. .old-price {
  365. padding-left: 8rpx;
  366. font-size: 26rpx;
  367. font-family: PingFang SC;
  368. font-weight: bold;
  369. text-decoration: line-through;
  370. color: #999999;
  371. }
  372. }
  373. }
  374. </style>