wholesale.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  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. time_id: this.wid
  183. }).then(res => {
  184. console.log(res, 'getNewList')
  185. this.newlist = res.data
  186. })
  187. },
  188. gotoDetail(item) {
  189. let obj = this
  190. obj.navto('/pages/product/realyWhole?id=' + item.id + '&time=' + item.time_id)
  191. },
  192. navto(url) {
  193. uni.navigateTo({
  194. url: url
  195. })
  196. },
  197. // // 获取剩余时间
  198. // getSyTime() {
  199. // let obj = this
  200. // let stopTime = timeComputed(obj.stop * 1000)
  201. // console.log(stopTime, 'stopTime')
  202. // obj.stopTimeH = stopTime.hours
  203. // obj.stopTimeM = stopTime.minutes >= 10 ? stopTime.minutes : ('0' + stopTime.minutes)
  204. // obj.stopTimeS = stopTime.seconds >= 10 ? stopTime.seconds : ('0' + stopTime.seconds)
  205. // if (stopTime.hours == 0 && stopTime.minutes == 0 && stopTime.seconds == 0) {
  206. // obj.status = 0
  207. // }
  208. // if (!obj.timer) {
  209. // if (obj.status == 1) {
  210. // obj.timer = setTimeout(this.getSyTime, 1000)
  211. // }
  212. // } else {
  213. // clearTimeout(obj.timer)
  214. // if (obj.status == 1) {
  215. // obj.timer = setTimeout(this.getSyTime, 1000)
  216. // }
  217. // }
  218. // // console.log(obj.stopTimeH + ':' + obj.stopTimeM + ':' + obj.stopTimeS)
  219. // },
  220. getWholeList() {
  221. let obj = this
  222. console.log('开始加载')
  223. // obj.loadingType == 'loading'
  224. if(obj.loadingType == 'noMore' || obj.loadingType == 'loading') {
  225. return
  226. }
  227. obj.loadingType = 'loading'
  228. getWholeList({
  229. page: obj.page,
  230. limit: obj.limit
  231. }, obj.wid).then(({
  232. data
  233. }) => {
  234. console.log('结束')
  235. obj.list = obj.list.concat(data.data)
  236. obj.page++
  237. if(data.data.length == obj.limit) {
  238. obj.loadingType = 'more'
  239. }else {
  240. obj.loadingType = 'noMore'
  241. }
  242. })
  243. },
  244. loadmore() {
  245. console.log('加载更多')
  246. }
  247. }
  248. }
  249. </script>
  250. <style lang="scss">
  251. .to-bg {
  252. width: 750rpx;
  253. height: 427rpx;
  254. background-color: #fff;
  255. }
  256. .top-tit {
  257. position: absolute;
  258. top: 170rpx;
  259. left: 0;
  260. right: 0;
  261. margin: auto;
  262. text-align: center;
  263. font-size: 30rpx;
  264. font-family: PingFang SC;
  265. font-weight: 500;
  266. color: #FFFFFF;
  267. }
  268. .top-time {
  269. position: absolute;
  270. top: 240rpx;
  271. left: 0;
  272. right: 0;
  273. margin: auto;
  274. font-size: 83rpx;
  275. text-align: center;
  276. font-family: PingFang SC;
  277. font-weight: bold;
  278. color: #FFFFFF;
  279. }
  280. .center-btn {
  281. padding: 20rpx 32rpx;
  282. background-color: #fff;
  283. margin-bottom: 20rpx;
  284. .center-logo {
  285. width: 83rpx;
  286. height: 106rpx;
  287. flex-shrink: 0;
  288. background-color: #eee;
  289. }
  290. .center-tit {
  291. padding-left: 30rpx;
  292. flex-grow: 1;
  293. font-size: 24rpx;
  294. font-family: PingFang SC;
  295. font-weight: 500;
  296. color: #999999;
  297. line-height: 1.5;
  298. .tit-top {
  299. font-size: 32rpx;
  300. font-family: PingFang SC;
  301. font-weight: bold;
  302. color: #333333;
  303. }
  304. }
  305. .look-more {
  306. width: 16rpx;
  307. height: 30rpx;
  308. flex-shrink: 0;
  309. }
  310. }
  311. .swiper-box {
  312. // background-color: red;
  313. // position: relative;
  314. }
  315. .good-wrap {
  316. display: flex;
  317. // padding: 0 0 20rpx 20rpx;
  318. padding-left: 20rpx;
  319. flex-wrap: wrap;
  320. }
  321. .good {
  322. width: 345rpx;
  323. height: 480rpx;
  324. margin-right: 20rpx;
  325. margin-bottom: 20rpx;
  326. background: #FFFFFF;
  327. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  328. border-radius: 10rpx;
  329. position: relative;
  330. .xrlb {
  331. position: absolute;
  332. display: inline-block;
  333. padding: 5rpx 10rpx;
  334. background-color: #FF4C4C;
  335. color: #fff;
  336. text-align: center;
  337. border-radius: 0 10rpx 10rpx 0;
  338. // width: 100rpx;
  339. top: 0;
  340. left: 0;
  341. }
  342. .goo-img {
  343. width: 345rpx;
  344. height: 345rpx;
  345. border-radius: 10rpx 10rpx 0 0;
  346. // background-color: #bfa;
  347. }
  348. .good-tit {
  349. padding: 15rpx 20rpx;
  350. font-size: 30rpx;
  351. font-family: PingFang SC;
  352. font-weight: bold;
  353. color: #333333;
  354. line-height: 35rpx;
  355. }
  356. .good-price {
  357. padding-left: 20rpx;
  358. justify-content: flex-start;
  359. .new-price {
  360. font-size: 36rpx;
  361. font-family: PingFang SC;
  362. font-weight: bold;
  363. color: #FF4C4C;
  364. }
  365. .old-price {
  366. padding-left: 8rpx;
  367. font-size: 26rpx;
  368. font-family: PingFang SC;
  369. font-weight: bold;
  370. text-decoration: line-through;
  371. color: #999999;
  372. }
  373. }
  374. }
  375. </style>