rush.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. <style lang="scss">
  2. .app-bg{
  3. position: absolute;
  4. image{width: 100vw;height: 55vw;}
  5. .bg-info{
  6. width: 100vw;
  7. height: 55vw;
  8. position: absolute;
  9. top: 0;
  10. .tip{
  11. background: rgba(253, 59, 57, 0.4);
  12. border-radius: 14px;
  13. font-size: 16px;
  14. padding: 10rpx 20rpx;
  15. color: #fff;
  16. }
  17. }
  18. }
  19. .tb-top {
  20. .sreach{
  21. background: #fff;
  22. border-radius: 32rpx;
  23. padding: 16rpx 32rpx;
  24. .icon{
  25. width: 46rpx;
  26. height: 46rpx;
  27. }
  28. input{
  29. width: calc(100% - 46rpx - 16rpx - 50px);
  30. font-size: 16px;
  31. }
  32. .search-btn{
  33. font-size: 14px;
  34. color: #FF4C4C;
  35. }
  36. }
  37. .order{
  38. width: 140rpx;
  39. background: #fd3b39;
  40. border-radius: 14px;
  41. font-size: 16px;
  42. color: #fff;
  43. margin-right: 10px;
  44. }
  45. }
  46. .app-body{
  47. position: relative;
  48. z-index: 9;
  49. padding: 0px 30rpx;
  50. .goods-list{
  51. margin: 10px 0;
  52. .item{
  53. background: #fff;
  54. position: relative;
  55. width: calc(50% - 10rpx);
  56. margin-right: 10rpx;
  57. margin-bottom: 20rpx;
  58. border-radius: 10rpx;
  59. &:nth-child(2n) {
  60. margin-left: 10rpx;
  61. margin-right:0;
  62. }
  63. .buy-out{
  64. position: absolute;
  65. top: 0;
  66. left: 0;
  67. right: 0;
  68. z-index: 2;
  69. image{ width: 86px;
  70. height: 74px;}
  71. }
  72. .img {
  73. width: 100%;
  74. height: calc(50vw - 20rpx);
  75. border-radius: 10rpx 10rpx 0 0;
  76. }
  77. .info{
  78. padding: 20rpx;
  79. .title{
  80. font-size: 16px;
  81. color: #303133;
  82. padding: 10rpx 0;
  83. }
  84. .price{
  85. font-size: 22px;
  86. color: red;
  87. font-weight: 500;
  88. text{
  89. font-size: 12px;
  90. }
  91. }
  92. }
  93. }
  94. }
  95. .pager{
  96. padding: 20rpx 0;
  97. width: 100%;
  98. .next{
  99. width: calc(50% - 40rpx);
  100. background-color: #fd3b39;
  101. margin-right: 10rpx;
  102. &:nth-child(2n){
  103. margin-left: 10rpx;
  104. margin-right: 0;
  105. }
  106. color: #fff;
  107. text-align: center;
  108. padding: 5px 0px;
  109. border-radius: 28px;
  110. &.not{
  111. background: #ccc;
  112. color: #fff;
  113. }
  114. }
  115. }
  116. .countdown{
  117. margin-top: 11px;
  118. font-size: 18px;
  119. text-align: center;
  120. }
  121. .countdown-time{
  122. margin-top: 11px;
  123. font-size: 22px;
  124. text-align: center;
  125. color: #fd3b39;
  126. }
  127. }
  128. </style>
  129. <template>
  130. <view>
  131. <view class="app-bg">
  132. <image src="/static/img/hall_bg.png"></image>
  133. <view class="bg-info fx-h fx-bc fx-ac">
  134. <view class="tip">{{ data.nickname }}馆长:{{ data.gz_name || "" }}</view>
  135. </view>
  136. </view>
  137. <uni-nav-bar color="#fff" :border="false" statusBar backgroundColor="transparent" left-icon="left" @clickLeft="utils.navigateBack()" fixed :title="data.nickname || '加载中..'"></uni-nav-bar>
  138. <view class="app-body" v-if="isType == 2">
  139. <view style="height: calc(55vw - 30px);"></view>
  140. <view class="tb-top fx-r">
  141. <view @tap="tapOpen" data-url="order/order" class="order fx-h fx-bc fx-ac">
  142. <view class="text">订单</view>
  143. </view>
  144. <view class="sreach fx-r fx-bc fx-ac fx-g1">
  145. <image class="icon" src="/static/img/tb-seach.png"></image>
  146. <input type="text" confirm-type="search" v-model="keyword" @confirm="tapInput" placeholder="请输入搜索挂售商品" placeholder-style="color: #B3B3B3;" />
  147. <view class="fx-g1"></view>
  148. <view class="search-btn" @tap="tapInput" v-if="keyword != ''">搜索</view>
  149. </view>
  150. </view>
  151. <view class="goods-list fx-r">
  152. <view class="item" v-for="item in listData" @tap="tapItem(item)">
  153. <view class="buy-out" v-if="item.is_buy == 1">
  154. <image src="/static/img/sOut1.png"></image>
  155. </view>
  156. <image class="img" mode="aspectFill" :src="item.image"></image>
  157. <view class="info">
  158. <view class="title">{{ item.name }}</view>
  159. <view class="fx-r">
  160. <view class="price"><text>¥</text>{{ item.hanging_price }}</view>
  161. <view class="fx-g1"></view>
  162. <view v-if="item.is_buy == 1" style="color: #787878;font-size: 14px;">已售完</view>
  163. </view>
  164. </view>
  165. </view>
  166. </view>
  167. <view class="pager fx-r fx-bc fx-ac">
  168. <view class="next" @tap="tapPve()" :class="page.page == 1 ? 'not' : ''">上一页</view>
  169. <view class="next" @tap="tapNext()" :class="page.isFoot ? 'not' : ''">下一页</view>
  170. </view>
  171. </view>
  172. <view class="app-body fx-h fx-bc fx-ac" v-if="isType == 1">
  173. <view style="height: calc(55vw - 30px);"></view>
  174. <image src="/static/img/hall_djs.png" style="width: 50vw;height: 69vw;"></image>
  175. <view class="countdown">客官请稍后,请{{ utils.date('H:i:s',data.radd_time) }}入场</view>
  176. <view class="countdown-time">入场倒计时:{{ utils.countdown(countdownTime) }}</view>
  177. </view>
  178. <view class="app-body fx-h fx-bc fx-ac" v-if="isType == 3">
  179. <view style="height: calc(55vw - 30px);"></view>
  180. <image src="/static/img/hall_djs.png" style="width: 50vw;height: 69vw;"></image>
  181. <view class="countdown-time">{{ error }}</view>
  182. </view>
  183. </view>
  184. </template>
  185. <script>
  186. let intervalId = 0;
  187. import {mapState,mapMutations } from 'vuex'
  188. export default {
  189. ...mapState(['user','lbs']),
  190. data() {
  191. return {
  192. keyword : "",
  193. data : [],
  194. h5Foot : 0,
  195. isType : 0,
  196. countdownTime : 0,
  197. isLoadPro : false,
  198. error : "",
  199. listData : [],
  200. page:{
  201. page:1,
  202. isLoad:false,
  203. isFoot:false
  204. },
  205. id : 0
  206. }
  207. },
  208. /**
  209. * 跳转的值
  210. * @param {Object} option
  211. */
  212. onLoad(option){
  213. this.id = option.id || 0;
  214. intervalId = setInterval(this.interval,1000);
  215. this.initView();
  216. uni.$on('rushBuy',this.rushBuy);
  217. },
  218. onShow() {
  219. if(this.isLoadPro) this.onShowIn();
  220. },
  221. onUnload() {
  222. uni.$off('rushBuy',this.rushBuy);
  223. clearInterval(intervalId);
  224. },
  225. methods: {
  226. /**
  227. * 是倒计时状态
  228. */
  229. initView:function(){
  230. uni.showLoading({ title: '提交数据..' });
  231. this
  232. .request
  233. .post("auctionItem",{id : this.id})
  234. .then(res => {
  235. uni.hideLoading();
  236. if (res.code == 200) {
  237. this.data = res.data;
  238. this.interval();
  239. } else {
  240. this.isType = 3;
  241. this.error = res.msg;
  242. }
  243. })
  244. .catch(err => {
  245. this.utils.Tip("加载失败,重新点击尝试!" + JSON.stringify(error));
  246. uni.hideLoading();
  247. });
  248. },
  249. interval:function(){
  250. if(this.isLoadPro) return;
  251. if(this.data.radd_time == null) return;
  252. let time = this.utils.strtotime() - this.data.radd_time;
  253. if(time >= 0) {
  254. this.isType = 2;
  255. this.isLoadPro = true;
  256. this.getData();
  257. } else {
  258. this.isType = 1;
  259. this.countdownTime = Math.abs(time);
  260. }
  261. },
  262. onShowIn:function(){
  263. if(this.data.radd_time == null) return;
  264. let time = this.utils.strtotime() - this.data.radd_time;
  265. if(time >= 0) {
  266. this.isType = 2;
  267. this.isLoadPro = true;
  268. this.getData();
  269. }
  270. },
  271. /**
  272. * 打开详情
  273. */
  274. tapItem:function(item){
  275. if(item.is_buy == 1) {
  276. this.utils.Tip("已售完了");
  277. return;
  278. }
  279. uni.navigateTo({
  280. url:"proItem?id=" + item.id + "&auction_id=" + this.id
  281. })
  282. },
  283. rushBuy:function(data) {
  284. let id = data.id;
  285. for(let i in this.listData) {
  286. if(this.listData[i].id == id) {
  287. this.$set(this.listData[i],'is_buy',1);
  288. }
  289. }
  290. },
  291. /**
  292. * 输入
  293. */
  294. tapInput:function(ev){
  295. this.page = {page:1,isLoad:false,isFoot:false};
  296. this.getData(true);
  297. },
  298. /**
  299. * 下拉加载
  300. */
  301. loadMoreData:function(){
  302. if(this.page.isFoot || this.page.isLoad) {
  303. return;
  304. }
  305. this.page.page ++;
  306. this.getData();
  307. },
  308. /**
  309. * 获取get数据
  310. */
  311. getData:function(isPull = false){
  312. if (this.page.isLoad) return;
  313. this.page.isLoad = true;
  314. uni.showLoading({ title: '获取数据中..'});
  315. var post = {};
  316. if(this.keyword != "") {
  317. post.keyword = this.keyword;
  318. }
  319. post.page = this.page.page;
  320. post.auction_id = this.id;
  321. this
  322. .request
  323. .post("auctionPro",post)
  324. .then(res => {
  325. uni.hideLoading();
  326. this.listData = res.data.list;
  327. this.page.isLoad = false;
  328. //是否到底
  329. if (res.data.list.length != res.data.pageSize) {
  330. this.page.isFoot = true;
  331. } else {
  332. this.page.isFoot = false;
  333. }
  334. })
  335. .catch(res=>{
  336. console.log(res);
  337. uni.hideLoading();
  338. uni.showModal({title: '系统提示',content: '加载失败,重新点击尝试!',showCancel: false});
  339. });
  340. },
  341. tapPve:function(){
  342. if(this.page.page > 1) {
  343. this.page.page = this.page.page - 1;
  344. this.getData();
  345. }
  346. },
  347. tapNext:function(){
  348. if(!this.page.isFoot) {
  349. this.page.page++;
  350. this.getData();
  351. } else {
  352. this.utils.Tip("没有下一页了");
  353. }
  354. },
  355. /**
  356. * 打开其他页面
  357. * @param {Object} ev
  358. */
  359. tapOpen: function(ev) {
  360. let url = ev.currentTarget.dataset.url
  361. uni.navigateTo({
  362. url: url
  363. });
  364. },
  365. /**
  366. * 返回上一页
  367. */
  368. tapBack: function () {
  369. uni.navigateBack({ delta: 1 });
  370. },
  371. }
  372. }
  373. </script>