oneMarket.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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. publishGoodsId: goods.id
  113. // buyNum: parseInt(this.num)
  114. }
  115. this.http.request({
  116. url: '/level-one-server/app/TbGoodsCart/addGoodsInShopCart',
  117. data: params,
  118. contentType: 'application/json; charset=utf-8',
  119. method: 'POST',
  120. success: res => {
  121. setTimeout(function() {
  122. uni.showToast({
  123. title: res.data.msg
  124. });
  125. }, 1000)
  126. }
  127. });
  128. },
  129. // 商品分类
  130. getGoodsType() {
  131. this.http.request({
  132. url: '/level-one-server/TbGoodsType/getList',
  133. success: res => {
  134. this.typeList = res.data.data
  135. this.typeList.map(item => {
  136. item.check=false
  137. })
  138. }
  139. });
  140. },
  141. scrolltolower() {
  142. this.getGoodsList()
  143. },
  144. toDetails(id) {
  145. this.$common.to('/pages/goodsDetails/goodsDetails?id=' + id)
  146. },
  147. back() {
  148. uni.switchTab({
  149. url: '/pages/index/index'
  150. });
  151. },
  152. rightClick() {
  153. this.show = true
  154. this.getGoodsType()
  155. },
  156. open() {
  157. // console.log('open');
  158. },
  159. close() {
  160. this.typeList.map(item => {
  161. if(item.check) this.typeCheck.push(item)
  162. })
  163. this.show = false
  164. },
  165. BtnClick(type) {
  166. type == 1 ? uni.navigateTo({
  167. url: '/pages/oneMarket/cart/cart'
  168. }) : uni.navigateTo({
  169. url: '/pages/oneMarket/order/order'
  170. })
  171. },
  172. typeClick(data) {
  173. this.typeList.map(item => {
  174. if(item.no == data.no) item.check=!item.check
  175. })
  176. this.$forceUpdate();
  177. }
  178. }
  179. }
  180. </script>
  181. <style lang="scss">
  182. .item {
  183. .title {
  184. padding: 5px;
  185. }
  186. .rows {
  187. width: 100%;
  188. .row {
  189. width: 33.33%;
  190. float: left;
  191. text-align: center;
  192. .out {
  193. padding: 6px;
  194. overflow: hidden;
  195. .int {
  196. padding: 5px;
  197. color: #213227;
  198. background-color: #eaf1fe;
  199. border-radius: 3px;
  200. font-size: 14px;
  201. overflow: hidden;
  202. &.active {
  203. color: $main-color;
  204. }
  205. }
  206. }
  207. }
  208. }
  209. }
  210. page {
  211. background-image: url(../../static/images/top-bg.png);
  212. background-size: 100% 400rpx;
  213. background-repeat: no-repeat;
  214. background-position: top;
  215. background-color: #f3f4f6;
  216. }
  217. .list {
  218. height: auto;
  219. border-radius: 10rpx;
  220. margin: 10rpx 20rpx 10rpx 20rpx;
  221. }
  222. .goods-item {
  223. margin-bottom: 8rpx;
  224. }
  225. .item-box {
  226. height: 230rpx;
  227. width: 86%;
  228. padding: 30rpx;
  229. background-color: #fff;
  230. border: 1rpx #FFF solid;
  231. margin: 10rpx 0rpx;
  232. border-radius: 10rpx;
  233. }
  234. .txt {
  235. /* height: 50rpx; */
  236. margin-bottom: 20rpx;
  237. }
  238. .t1 {
  239. font-size: 32rpx;
  240. font-weight: bold;
  241. word-wrap: break-word;
  242. position: relative;
  243. top: 1rpx;
  244. right: 5rpx;
  245. }
  246. .t4 {
  247. display: flex;
  248. position: relative;
  249. bottom: 1rpx;
  250. right: 5rpx;
  251. }
  252. .price {
  253. color: #ef732a;
  254. width: 400rpx;
  255. font-weight: bold;
  256. }
  257. .car {
  258. background-color: #0081ff;
  259. width: 80rpx;
  260. height: 70rpx;
  261. border-radius: 40rpx;
  262. text-align: center;
  263. display: flex;
  264. align-items: center;
  265. justify-content: center;
  266. }
  267. .tab {
  268. position: fixed;
  269. bottom: 1rpx;
  270. width: 100%;
  271. height: 100rpx;
  272. display: flex;
  273. align-items: center;
  274. justify-content: center;
  275. border-top: #ffffff 1rpx solid;
  276. background-color: #ffffff;
  277. }
  278. .tabBtn {
  279. width: 35%;
  280. height: 100%;
  281. display: flex;
  282. align-items: center;
  283. justify-content: center;
  284. margin: 0 30rpx;
  285. }
  286. .pop {
  287. width: 400rpx;
  288. margin-top: 200rpx;
  289. }
  290. .custom-style {
  291. width: 300rpx;
  292. }
  293. /* .active-btn {
  294. width: 35%;
  295. height: 100%;
  296. display: flex;
  297. align-items: center;
  298. justify-content: center;
  299. color: #fff;
  300. background-color: #00BFFF;
  301. } */
  302. </style>