depotAcquisition.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. <template>
  2. <view class="">
  3. <view class="header">
  4. <view class='locationwrap' @click='naviageToPage("/pages/user/depotAcquisition/selectCity")'>
  5. {{currentCityName}}
  6. <u-icon name="arrow-down" size="28" class="icon-jt"></u-icon>
  7. </view>
  8. <u-search class="search" bg-color="#F5F6F9" placeholder="请输入仓库名" v-model="searchKeyWord"
  9. :show-action="false" @change="searchChange"></u-search>
  10. <!-- <view @click='naviageToPage("/pages/user/depotAcquisition/grainDeliveryRecord")'
  11. class='Regular flex align-item-center distribution justify-center'>
  12. <image class='cangku' src="../../../static/img/liangmai/cangku.png" mode=""></image>
  13. </view> -->
  14. </view>
  15. <view class="content1" v-for="(item,index) in dataList" :key="index">
  16. <view class="row row1">
  17. <view class="title">{{item.warehouseName}}</view>
  18. <view class='follow' @click="followClick(item)">{{item.followFlag=='0'?'+关注':'已关注'}}</view>
  19. </view>
  20. <view class="row2">
  21. <view class='position'>
  22. <image class='location' src="../../../static/img/liangmai/icon_ditu.png" mode=""></image>
  23. {{item.warehousePrivate}}{{item.warehouseCity}}{{item.warehouseArea}}{{item.detailedAddress}}
  24. </view>
  25. </view>
  26. <view class="row3">
  27. <view class="row3-item">
  28. <u-read-more color='#22C572' show-height="140" :index="index" :shadow-style="shadowStyle"
  29. :toggle="true" close-text="展开阅读更多内容" @open='open' @close='close'>
  30. <rich-text :nodes="item.acquisitionInformation" class="rich-item"></rich-text>
  31. <!-- @load="parseLoaded" -->
  32. <!-- <u-parse :html="item.content" ></u-parse> -->
  33. </u-read-more>
  34. </view>
  35. </view>
  36. <view class="row4">
  37. <view class="time">{{item.createDate}}</view>
  38. <view class="btn"
  39. @click='naviageToPage("/pages/user/depotAcquisition/grainDeliveryRegistration?itemValue="+JSON.stringify(item))'>
  40. 我要送粮
  41. </view>
  42. </view>
  43. </view>
  44. <u-modal v-model="isShowAlert" :title-style="{fontSize: '18px',fontWeight:'500'}"
  45. :content-style="{fontSize: '14px',fontWeight:'400'}" confirm-color='#22C572' confirm-text='确定' title='登录提示'
  46. showCancelButton='false' :content="content" @confirm="alertBtn" @cancel="cancelClick"></u-modal>
  47. </view>
  48. </template>
  49. <script>
  50. import {
  51. mapState
  52. } from 'vuex';
  53. export default {
  54. components: {
  55. },
  56. data() {
  57. return {
  58. isShowAlert: false,
  59. content: '当前登入信息验证失败,是否重新登录?',
  60. currentCityName: '',
  61. searchKeyWord: '',
  62. shadowStyle: {
  63. backgroundImage: "none",
  64. paddingTop: "0",
  65. marginTop: "20rpx",
  66. },
  67. dataList: [],
  68. currentPage: 1,
  69. pageSize: 10,
  70. loadStatus: 'loading',
  71. isLoadMore: false,
  72. }
  73. },
  74. onLoad() {
  75. },
  76. // #ifndef MP
  77. onNavigationBarButtonTap(e) {
  78. const index = e.index;
  79. if (index == 1) {
  80. uni.navigateBack()
  81. } else {
  82. this.naviageToPage("/pages/user/depotAcquisition/grainDeliveryRecord")
  83. }
  84. },
  85. // #endif
  86. computed: {
  87. ...mapState(['hasLogin', 'userInfo']),
  88. },
  89. onReachBottom() { //上拉触底函数
  90. if (!this.isLoadMore) { //此处判断,上锁,防止重复请求
  91. this.isLoadMore = true
  92. this.currentPage += 1
  93. this.getListData()
  94. }
  95. },
  96. onPullDownRefresh() {
  97. this.currentPage = 1
  98. this.isLoadMore = false
  99. this.loadStatus = 'loading'
  100. this.dataList = []
  101. this.getListData()
  102. setTimeout(function() {
  103. uni.stopPullDownRefresh();
  104. }, 1000);
  105. },
  106. onShow() {
  107. let _city = uni.getStorageSync("depotAcquisition_selectCity")
  108. this.currentCityName = _city ? _city.positionName.cityName : ''
  109. this.$api.doRequest('get', '/commonUser/api/checkSession').then(res => {
  110. console.log("checkSession", res)
  111. if (res.data.data == "INVALID") {
  112. this.isShowAlert = true;
  113. }
  114. this.currentPage = 1
  115. this.isLoadMore = false
  116. this.loadStatus = 'more'
  117. this.getListData()
  118. })
  119. console.log("hasLogin", this.hasLogin)
  120. },
  121. methods: {
  122. getListData() {
  123. if (this.currentCityName == '全国') this.currentCityName = ''
  124. this.$api.doRequest('get', '/acquisitionInfo/selectAcquisitionPage', {
  125. searchKeyWord: this.searchKeyWord,
  126. city: this.currentCityName,
  127. compId: uni.getStorageSync('pcUserInfo').compId,
  128. loginPhone:uni.getStorageSync("userInfo").phone,
  129. }).then(res => {
  130. if (res.data.code == "200") {
  131. if (this.currentCityName == '') this.currentCityName = '全国'
  132. this.dataList = res.data.data
  133. this.isLoadMore = true
  134. this.loadStatus = 'nomore'
  135. }
  136. })
  137. },
  138. followClick(val) {
  139. let _url = ''
  140. if(val.followFlag==1){
  141. _url = '/acquisitionInfo/api/followNot'
  142. }else{
  143. _url = '/acquisitionInfo/api/follow'
  144. }
  145. this.$api.doRequest('post', _url, {
  146. id: val.id,
  147. commonId: uni.getStorageSync("userInfo").id,
  148. }).then(res => {
  149. if (res.data.code == "200") {
  150. if (res.data.data == '1') {
  151. val.followFlag = '1'
  152. this.$api.msg('关注成功')
  153. } else {
  154. val.followFlag = '0'
  155. this.$api.msg('取消关注成功')
  156. }
  157. this.$forceUpdate()
  158. }
  159. })
  160. // this.$api.doRequest('post', '/acquisitionInfo/api/editFollowFlag', {
  161. // id: val.id,
  162. // commonId: uni.getStorageSync("userInfo").id,
  163. // }).then(res => {
  164. // if (res.data.code == "200") {
  165. // if (res.data.data == '1') {
  166. // val.followFlag = '1'
  167. // this.$api.msg('关注成功')
  168. // } else {
  169. // val.followFlag = '0'
  170. // this.$api.msg('取消关注成功')
  171. // }
  172. // this.$forceUpdate()
  173. // }
  174. // })
  175. },
  176. open(e) {
  177. console.log(e)
  178. },
  179. close(e) {
  180. console.log(e)
  181. },
  182. /**
  183. * 统一跳转接口,拦截未登录路由
  184. * navigator标签现在默认没有转场动画,所以用view
  185. */
  186. naviageToPage(url) {
  187. if (!this.hasLogin) {
  188. url = '/pages/public/login';
  189. }
  190. uni.navigateTo({
  191. url
  192. })
  193. },
  194. alertBtn() {
  195. uni.navigateTo({
  196. url: '/pages/public/login'
  197. })
  198. },
  199. cancelClick() {
  200. this.isShowAlert = false
  201. },
  202. searchChange(e) {
  203. console.log(e)
  204. this.getListData()
  205. }
  206. }
  207. }
  208. </script>
  209. <style lang='scss' scoped>
  210. page {
  211. background: #F5F6FA;
  212. }
  213. .wrap {
  214. background: #fff;
  215. margin: 10px;
  216. border-radius: 10px;
  217. padding: 10px;
  218. /* position: relative; */
  219. top: 20rpx;
  220. }
  221. .header {
  222. padding: 25rpx;
  223. background: #fff;
  224. border-radius: 0 0 10px 10px;
  225. display: flex;
  226. justify-content: space-between;
  227. align-items: center;
  228. position: relative;
  229. /deep/.u-content {
  230. padding-left: 180rpx;
  231. }
  232. }
  233. .location {
  234. width: 32rpx;
  235. height: 32rpx;
  236. margin-right: 10rpx;
  237. }
  238. .locationwrap {
  239. font-size: 16px;
  240. display: flex;
  241. align-items: center;
  242. position: absolute;
  243. top: 0;
  244. bottom: 0;
  245. margin: auto;
  246. /* height: 100%; */
  247. left: 60rpx
  248. }
  249. .cangku {
  250. width: 16.5px;
  251. height: 16.5px;
  252. margin-right: 5px;
  253. }
  254. .search {}
  255. .rich-item {
  256. line-height: 46rpx;
  257. }
  258. .row1 {
  259. display: flex;
  260. justify-content: space-between;
  261. }
  262. .row4 {
  263. display: flex;
  264. align-items: center;
  265. justify-content: space-between;
  266. .btn {
  267. background: #22C572;
  268. border-radius: 40rpx;
  269. font-size: 28rpx;
  270. font-weight: 400;
  271. color: #FFFFFF;
  272. padding: 10rpx 30rpx;
  273. }
  274. .time {
  275. color: #878C9C;
  276. margin: 20rpx 0;
  277. }
  278. }
  279. .icon-jt {
  280. margin-left: 20rpx;
  281. }
  282. .content1 {
  283. background: white;
  284. margin: 20rpx;
  285. padding: 30rpx;
  286. border-radius: 20rpx;
  287. .row1 {
  288. .title {
  289. font-size: 32rpx;
  290. font-weight: 500;
  291. color: #333333;
  292. }
  293. .follow {
  294. border: 1px solid #EEEEEE;
  295. font-weight: 400;
  296. color: #878C9C;
  297. padding: 9rpx 28rpx;
  298. border-radius: 40rpx;
  299. }
  300. }
  301. .row2 {
  302. .position {
  303. margin: 20rpx 0;
  304. font-size: 12px;
  305. color: #676E80;
  306. background: #F5F6FA;
  307. padding: 0rpx 20rpx;
  308. height: 50rpx;
  309. display: flex;
  310. align-items: center;
  311. border-radius: 50rpx;
  312. }
  313. }
  314. }
  315. </style>