index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <template>
  2. <div class="container">
  3. <div class="header">
  4. <h2 class="title">贷款产品</h2>
  5. </div>
  6. <div class="better-scroll wrapper" ref="wrapper">
  7. <ul>
  8. <li class="list bg-1" v-for="(item, index) in listData" :key="index" @click="funJumpDetail(item)">
  9. <div class="top">
  10. <div class="left-wrap">
  11. <img :src="item.productLogUrl" alt="">
  12. </div>
  13. <div class="right-wrap">
  14. <p>{{ item.productName }}</p>
  15. <p>
  16. <span>最高:</span>
  17. <span class="col-1">{{ item.productPrice / 10000 }}</span>
  18. <span class="col-1">万元</span>
  19. </p>
  20. </div>
  21. </div>
  22. </li>
  23. <li class="load-status" v-if="listData.length && booFetchData">
  24. <p>{{ arrFetchStatus[numFetchStatus] }}</p>
  25. </li>
  26. <li class="bitmap" v-if="!listData.length && booFetchData">
  27. <p>暂无申请记录</p>
  28. </li>
  29. </ul>
  30. </div>
  31. <Poster :posterBg="posterBg"
  32. :codeParams="codeParams"
  33. ref="myPoster"/>
  34. </div>
  35. </template>
  36. <script>
  37. import BScroll from 'better-scroll'
  38. import { Toast } from 'vant'
  39. import Poster from '../poster'
  40. import { productList } from './api'
  41. const PAGESIZE = 20
  42. export default {
  43. name: 'goods',
  44. components: {
  45. Poster
  46. },
  47. props: {
  48. partnerId: {
  49. type: String,
  50. default: ''
  51. },
  52. partnerName: {
  53. type: String,
  54. default: ''
  55. },
  56. partnerImgUrl: {
  57. type: String,
  58. default: ''
  59. }
  60. },
  61. data () {
  62. return {
  63. pager: {
  64. pagenum: 1,
  65. pagesize: PAGESIZE,
  66. pagecount: 1
  67. },
  68. listData: [],
  69. scroll: null,
  70. numFetchStatus: 0,
  71. arrFetchStatus: ['正在加载,请稍后~', '上拉加载更多', '没有更多了', '出错啦'],
  72. booFetchData: false,
  73. numPositionY: 0,
  74. posterBg: '',
  75. codeParams: {
  76. link: '',
  77. x: 124,
  78. y: 1174,
  79. width: 202,
  80. height: 202
  81. }
  82. }
  83. },
  84. activated () {
  85. if (!this.$route.meta.isUseCache) {
  86. this.pager = {
  87. pagenum: 1,
  88. pagesize: PAGESIZE,
  89. pagecount: 1
  90. }
  91. this.listData = []
  92. this.numFetchStatus = 0
  93. this.booFetchData = false
  94. this.numPositionY = 0
  95. this.funFetch()
  96. } else {
  97. this.$nextTick(() => {
  98. if (this.scroll) {
  99. this.scroll.refresh()
  100. this.scroll.scrollTo(0, this.numPositionY)
  101. }
  102. })
  103. }
  104. this.$nextTick(() => {
  105. this.$refreshTitle('贷款产品')
  106. })
  107. },
  108. methods: {
  109. funFetch () {
  110. const vm = this
  111. vm.numFetchStatus = 0
  112. productList(vm.pager.pagenum, vm.pager.pagesize).then(response => {
  113. if (response.status) {
  114. const data = response.data
  115. const temp = data.data
  116. vm.pager.pagecount = Math.ceil(data.count / PAGESIZE)
  117. vm.pager.pagenum++
  118. vm.booFetchData = true
  119. if (vm.pager.pagecount <= 1) {
  120. vm.numFetchStatus = 2
  121. } else {
  122. vm.numFetchStatus = 1
  123. }
  124. if (temp.length) {
  125. vm.listData = vm.listData.concat(temp)
  126. vm.$nextTick(() => {
  127. if (!vm.scroll) {
  128. vm.scroll = new BScroll(vm.$refs.wrapper, {
  129. click: true,
  130. pullUpLoad: {
  131. threshold: -20
  132. },
  133. scrollbar: true
  134. })
  135. vm.scroll.on('pullingUp', () => {
  136. if (vm.pager.pagenum > vm.pager.pagecount) {
  137. vm.numFetchStatus = 2
  138. return
  139. }
  140. vm.funFetch()
  141. })
  142. } else {
  143. vm.scroll.refresh()
  144. vm.scroll.finishPullUp()
  145. }
  146. })
  147. }
  148. } else {
  149. Toast(response.msg)
  150. vm.numFetchStatus = 3
  151. }
  152. }).catch(() => {
  153. Toast('出错啦')
  154. vm.numFetchStatus = 3
  155. })
  156. },
  157. funJumpDetail (item) {
  158. const { id, productShareUrl } = item
  159. this.posterBg = productShareUrl
  160. this.$set(this.codeParams, 'link', `${location.origin}/loan/explain/${id}?partnerId=${this.partnerId}`)
  161. this.$nextTick(() => {
  162. console.log(this.codeParams)
  163. this.$refs.myPoster.createQRCode()
  164. })
  165. }
  166. }
  167. }
  168. </script>
  169. <style lang="scss" scoped>
  170. .container {
  171. display: flex;
  172. flex-direction: column;
  173. align-items: center;
  174. width: 100%;
  175. background: #fff;
  176. }
  177. .header {
  178. display: flex;
  179. flex-direction: column;
  180. align-items: center;
  181. width: 100%;
  182. padding: 25px 0 24px;
  183. }
  184. .title {
  185. width: 343px;
  186. padding-left: 8px;
  187. line-height: 33px;
  188. font-size: 24px;
  189. font-weight: 500;
  190. color: #333;
  191. }
  192. .wrapper {
  193. position: relative;
  194. width: 100%;
  195. height: calc(100vh - 82px);
  196. overflow: hidden;
  197. ul {
  198. display: flex;
  199. flex-direction: column;
  200. align-items: center;
  201. width: 100%;
  202. padding-bottom: 80px;
  203. }
  204. }
  205. .list {
  206. position: relative;
  207. left: 0;
  208. top: 0;
  209. display: flex;
  210. flex-direction: column;
  211. align-items: center;
  212. width: 343px;
  213. margin-bottom: 26px;
  214. border-radius: 4px;
  215. &.bg-0 {
  216. background: linear-gradient(270deg, #E2E2E2 0%, #C7C7C7 100%);
  217. }
  218. &.bg-1 {
  219. background: linear-gradient(90deg, #44403B 0%, #93806B 100%);
  220. }
  221. }
  222. .top {
  223. display: flex;
  224. align-items: center;
  225. width: 297px;
  226. padding: 18px 0 12px;
  227. }
  228. .left-wrap {
  229. width: 60px;
  230. height: 60px;
  231. border-radius: 4px;
  232. overflow: hidden;
  233. img {
  234. display: block;
  235. width: 100%;
  236. }
  237. }
  238. .right-wrap {
  239. margin-left: 18px;
  240. p:nth-of-type(1) {
  241. line-height: 25px;
  242. font-size: 18px;
  243. font-weight: 500;
  244. color: #fff;
  245. }
  246. p:nth-of-type(2) {
  247. display: flex;
  248. align-items: flex-end;
  249. span:nth-of-type(1) {
  250. padding-bottom: 5px;
  251. line-height: 20px;
  252. font-size: 15px;
  253. color: #fff;
  254. }
  255. span:nth-of-type(2) {
  256. line-height: 33px;
  257. font-size: 24px;
  258. font-weight: bold;
  259. }
  260. span:nth-of-type(3) {
  261. padding-bottom: 4px;
  262. line-height: 20px;
  263. font-size: 15px;
  264. font-weight: bolder;
  265. }
  266. .col-0 {
  267. color: #A7A7A7;
  268. }
  269. .col-1 {
  270. color: #D6BDA1;
  271. }
  272. }
  273. }
  274. .load-status {
  275. margin-top: 12px;
  276. p {
  277. line-height: 20px;
  278. font-size: 14px;
  279. color: #666;
  280. text-align: center;
  281. }
  282. }
  283. .bitmap {
  284. p {
  285. line-height: 22px;
  286. font-size: 16px;
  287. font-weight: 500;
  288. text-align: center;
  289. color: #333;
  290. }
  291. }
  292. </style>