oneMarket.vue 7.0 KB

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