oneMarket.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. <template>
  2. <view>
  3. <!-- <image src="../../static/images/top-bg.png"></image> -->
  4. <!-- <navigation-bar :title="title" background-color="#fff" front-color="#000000" :left-button="null" /> -->
  5. <uni-nav-bar color="#fff" height="60" left-icon="back" @clickLeft="back()" @clickRight="rightClick()"
  6. right-icon="list" :border="false" backgroundColor="#0081ff" title="一级市场" />
  7. </u-navbar>
  8. <u-list v-if="active==1" class="list" width="100%" @scrolltolower="scrolltolower">
  9. <u-list-item v-for="(item, index) in goods" :key="index">
  10. <view class="item-box">
  11. <view class="goods-item">
  12. <u-row>
  13. <u-col span="5" @click="toDetails(item.id)">
  14. <u--image :showLoading="true" src="" width="270rpx" height="220rpx"></u--image>
  15. </u-col>
  16. <u-col span="7">
  17. <view class="t1 txt" @click="toDetails(item.id)">
  18. <text>{{item.goodsName}}</text>
  19. <!-- <text>[老板力荐]鲜活小龙虾(帮剪头去虾线)约250g/份</text> -->
  20. </view>
  21. <view class="txt">
  22. <text v-if="item.grossWeight">{{item.grossWeight}}吨</text>
  23. </view>
  24. <view class="txt" v-if="item.tradeAreaName">
  25. <u-tag style="width: 250rpx" :text="item.tradeAreaName" plain size="mini"></u-tag>
  26. </view>
  27. <view class="t4">
  28. <view class="price">¥{{item.price}}</view>
  29. <view class="car" @click="addCar(item)">
  30. <u-icon color="#fff" name="shopping-cart-fill" size="30"></u-icon>
  31. </view>
  32. </view>
  33. </u-col>
  34. </u-row>
  35. </view>
  36. </view>
  37. </u-list-item>
  38. </u-list>
  39. <u-popup :show="show" mode="right" @close="close" @open="open">
  40. <view class="pop" style="padding: 15px;">
  41. <view class="item">
  42. <view class="title">生鲜海鲜</view>
  43. <view class="rows">
  44. <view class="row omit" v-for="(item, index) in typeList" :key="index">
  45. <view class="out">
  46. <view class="int" :style="{color:index==5?'#0081FF':'#213227'}">{{item.name}}</view>
  47. </view>
  48. </view>
  49. <view class="clear"></view>
  50. </view>
  51. </view>
  52. <view class="item">
  53. <view class="title">生鲜海鲜</view>
  54. <view class="rows">
  55. <view class="row omit" v-for="(item, index) in typeList" :key="index">
  56. <view class="out">
  57. <view class="int" :active="{active:true}">{{item.name}}</view>
  58. </view>
  59. </view>
  60. <view class="clear"></view>
  61. </view>
  62. </view>
  63. <!-- <view class="u-page__tag-item" style="display: flex; align-items: center;"
  64. v-for="(item, index) in typeList" :key="index">
  65. <u-tag class="tag" :text="item.name" :plain="!item.checked" :name="item.no" @click="checkboxClick">
  66. </u-tag>
  67. </view> -->
  68. <u-button class="custom-style" shape="circle" type="primary" size="small" text="确定"
  69. @click="close()"></u-button>
  70. </view>
  71. </u-popup>
  72. <view class="tab">
  73. <view class="tabBtn" @click="BtnClick(1)">
  74. <u-icon label="购物车" size="30" color="#ef732a" labelColor="#ef732a" name="shopping-cart"></u-icon>
  75. </view>
  76. <view class="tabBtn" @click="BtnClick(2)">
  77. <u-icon label="订单列表" size="30" color="#1E90FF" labelColor="#1E90FF" name="order"></u-icon>
  78. </view>
  79. </view>
  80. </view>
  81. </template>
  82. <script>
  83. export default {
  84. data() {
  85. return {
  86. loadmoreStatus: 'loadmore',
  87. goods: [],
  88. active: 1,
  89. title: '一级市场',
  90. show: false,
  91. typeList: [],
  92. }
  93. },
  94. onLoad() {
  95. this.getGoodsList()
  96. },
  97. // onShow() {
  98. // var a = document.getElementsByClassName('uni-page-head-hd')[0]
  99. // a.style.display = 'none';
  100. // },
  101. methods: {
  102. getGoodsList() {
  103. let form = {
  104. isOrders: 0,//是否已被下单[0=未被下单,1=已被下单]
  105. //enterpriseConfirm: ,//商铺确认情况[0=待确认,1=已确认,2=拒绝]
  106. goodsStatus: 1,//商品状态(0=下架,1=在售)
  107. }
  108. this.http.request({
  109. url: '/level-one-server/TbGoodsTransit/getTransitList',
  110. data: form,
  111. success: res => {
  112. this.goods = res.data.data;
  113. this.goods.forEach((item, index) => {
  114. if (index === this.goods.length - 1) {
  115. this.loadmoreStatus = 'nomore'
  116. } else {
  117. this.loadmoreStatus = 'loadmore'
  118. }
  119. })
  120. }
  121. });
  122. },
  123. // 添加购物车
  124. addCar(goods) {
  125. let user = uni.getStorageSync("info")
  126. let params = {
  127. buyUserId: user.id,
  128. enterpriseId: goods.merchantId,
  129. shopId: goods.shopId,
  130. tradeAreaId: goods.tradeAreaId,
  131. saleGoodsInfoId: goods.id,
  132. goodsImg: goods.goodsImg,
  133. goodsName: goods.goodsName,
  134. // buyNum: parseInt(this.num)
  135. }
  136. console.log(goods)
  137. this.http.request({
  138. url: '/level-one-server/app/TbGoodsCart/addGoodsInShopCart',
  139. data: params,
  140. contentType: 'application/json; charset=utf-8',
  141. method: 'POST',
  142. success: res => {
  143. setTimeout(function() {
  144. uni.showToast({
  145. title: res.data.data.msg
  146. });
  147. }, 1000)
  148. }
  149. });
  150. },
  151. // 商品分类
  152. getGoodsType() {
  153. this.http.request({
  154. url: '/level-one-server/TbGoodsType/getList',
  155. success: res => {
  156. this.typeList = res.data.data
  157. console.log(this.typeList)
  158. }
  159. });
  160. },
  161. scrolltolower() {
  162. this.getGoodsList()
  163. },
  164. toDetails(id) {
  165. this.$common.to('/pages/goodsDetails/goodsDetails?id=' + id)
  166. },
  167. // change(index) {
  168. // console.log(index)
  169. // this.active = index
  170. // },
  171. // tabClick(id) {
  172. // this.active = id
  173. // if (id == 1) {
  174. // this.title = '一级市场'
  175. // } else if (id == 2) {
  176. // this.title = '购物车'
  177. // } else {
  178. // this.title = '订单列表'
  179. // }
  180. // },
  181. back() {
  182. uni.switchTab({
  183. url: '/pages/index/index'
  184. });
  185. },
  186. rightClick() {
  187. this.show = true
  188. this.getGoodsType()
  189. },
  190. open() {
  191. // console.log('open');
  192. },
  193. close() {
  194. this.show = false
  195. // console.log('close');
  196. },
  197. BtnClick(type) {
  198. type == 1 ? uni.navigateTo({
  199. url: '/pages/oneMarket/cart/cart'
  200. }) : uni.navigateTo({
  201. url: '/pages/oneMarket/order/order'
  202. })
  203. },
  204. checkboxClick(name) {
  205. this.typeList.map((item, index) => {
  206. if (item.no == name) item.checked = true
  207. })
  208. }
  209. }
  210. }
  211. </script>
  212. <style lang="scss">
  213. .item {
  214. .title {
  215. padding: 5px;
  216. }
  217. .rows {
  218. width: 100%;
  219. .row {
  220. width: 33.33%;
  221. float: left;
  222. text-align: center;
  223. .out {
  224. padding: 6px;
  225. overflow: hidden;
  226. .int {
  227. padding: 5px;
  228. color: #213227;
  229. background-color: #eaf1fe;
  230. border-radius: 3px;
  231. font-size: 14px;
  232. overflow: hidden;
  233. &.active {
  234. color: $main-color;
  235. }
  236. }
  237. }
  238. }
  239. }
  240. }
  241. page {
  242. background-image: url(../../static/images/top-bg.png);
  243. background-size: 100% 400rpx;
  244. background-repeat: no-repeat;
  245. background-position: top;
  246. background-color: #f3f4f6;
  247. }
  248. .list {
  249. height: auto;
  250. border-radius: 10rpx;
  251. margin: 15rpx;
  252. }
  253. .goods-item {
  254. margin-bottom: 8rpx;
  255. }
  256. .item-box {
  257. height: 230rpx;
  258. width: 90%;
  259. padding: 20rpx;
  260. background-color: #fff;
  261. border: 1rpx #FFF solid;
  262. margin: 10rpx 0rpx;
  263. border-radius: 10rpx;
  264. }
  265. .txt {
  266. /* height: 50rpx; */
  267. margin-bottom: 20rpx;
  268. }
  269. .t1 {
  270. font-size: 32rpx;
  271. font-weight: bold;
  272. word-wrap: break-word;
  273. position: relative;
  274. top: 1rpx;
  275. right: 5rpx;
  276. }
  277. .t4 {
  278. display: flex;
  279. position: relative;
  280. bottom: 1rpx;
  281. right: 5rpx;
  282. }
  283. .price {
  284. color: #ef732a;
  285. width: 400rpx;
  286. font-weight: bold;
  287. }
  288. .car {
  289. background-color: #0081ff;
  290. width: 60rpx;
  291. height: 60rpx;
  292. border-radius: 30rpx;
  293. text-align: center;
  294. display: flex;
  295. align-items: center;
  296. justify-content: center;
  297. }
  298. .tab {
  299. position: fixed;
  300. bottom: 1rpx;
  301. width: 100%;
  302. height: 100rpx;
  303. display: flex;
  304. align-items: center;
  305. justify-content: center;
  306. border-top: #ffffff 1rpx solid;
  307. background-color: #ffffff;
  308. }
  309. .tabBtn {
  310. width: 35%;
  311. height: 100%;
  312. display: flex;
  313. align-items: center;
  314. justify-content: center;
  315. margin: 0 30rpx;
  316. }
  317. .pop {
  318. width: 400rpx;
  319. margin-top: 200rpx;
  320. }
  321. .custom-style {
  322. width: 300rpx;
  323. }
  324. .tag {
  325. margin-bottom: 30rpx;
  326. display: flex;
  327. align-items: center;
  328. /* width: 300rpx;
  329. height: 50rpx;
  330. background-color: #f3f4f6;
  331. border-radius: 10rpx;
  332. text-align: center; */
  333. }
  334. /* .active-btn {
  335. width: 35%;
  336. height: 100%;
  337. display: flex;
  338. align-items: center;
  339. justify-content: center;
  340. color: #fff;
  341. background-color: #00BFFF;
  342. } */
  343. </style>