index.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. <template>
  2. <div class="wrapper">
  3. <img class="banner"
  4. :src="productInfo.productContentUrl"
  5. alt="">
  6. <!--合伙人推广-->
  7. <div class="footer myself" v-if="partnerId">
  8. <router-link class="btn-apply single"
  9. :to="{path: '/loan/apply/' + orderProductId, query: { partnerId }}">点击预约办理
  10. </router-link>
  11. </div>
  12. <!--妥妥:本人-->
  13. <div class="footer myself" v-else-if="!recommendedUser.id">
  14. <!--可以分享-->
  15. <template v-if="userShareConfig.share">
  16. <router-link class="btn-apply double"
  17. :to="{path: '/loan/apply/' + orderProductId}">点击申请
  18. </router-link>
  19. <a class="invite double"
  20. href="javascript:;"
  21. @click="booInvite = true">分享好礼</a>
  22. </template>
  23. <!--不能分享-->
  24. <router-link class="btn-apply single"
  25. :to="{path: '/loan/apply/' + orderProductId}"
  26. v-else>点击申请
  27. </router-link>
  28. </div>
  29. <!--妥妥:非本人-->
  30. <div class="footer other" v-else>
  31. <router-link class="btn-apply single"
  32. :to="{path: '/loan/apply/' + orderProductId, query: { RId: recommendedUser.id }}">点击预约办理
  33. </router-link>
  34. <div class="partner-info">
  35. <div class="partner-avatar">
  36. <img :src="recommendedUser.userImgUrl" alt="">
  37. </div>
  38. <p class="name">{{ recommendedUser.userName }} 邀请你</p>
  39. </div>
  40. </div>
  41. <!--生成二维码使用-->
  42. <div id="ttyf-qrcode"
  43. style="display: none;"></div>
  44. <!--弹窗:邀请-->
  45. <van-popup class="ttyf-van-popup-invite"
  46. round
  47. v-model="booInvite">
  48. <p class="title">邀请好友申请贷款</p>
  49. <p class="tip">放款成功后,可获得超值奖励</p>
  50. <p class="btns">
  51. <a href="javascript:;" @click="funShareTip">微信好友 邀请</a>
  52. <a href="javascript:;" @click="funShareTip">微信朋友圈 邀请</a>
  53. </p>
  54. <p class="show-code"
  55. @click="funShowCode">
  56. <img src="./image/icon_00@2x.png" alt="">
  57. <span>面对面扫码邀请></span>
  58. </p>
  59. </van-popup>
  60. <!--弹窗:二维码-->
  61. <van-popup class="ttyf-van-popup-code"
  62. round
  63. v-model="booCode">
  64. <p>请扫码申请贷款</p>
  65. <div class="qrcode-wrap">
  66. <img :src="codeUrl" alt="">
  67. </div>
  68. </van-popup>
  69. <!--弹窗:分享提示-->
  70. <van-popup class="ttyf-van-popup-share"
  71. position="top"
  72. v-model="booShareTip">
  73. <img src="./image/icon_01@2x.png" alt="">
  74. </van-popup>
  75. </div>
  76. </template>
  77. <script>
  78. import { Popup, Toast } from 'vant'
  79. import { funWxShare } from '../../../utils/wxShareConfig'
  80. import { getProductDetail } from '../../../api/common'
  81. import QRCode from 'qrcodejs2'
  82. import { getUserShare } from './api'
  83. export default {
  84. name: 'explain',
  85. components: {
  86. 'van-popup': Popup
  87. },
  88. props: {
  89. // 产品ID
  90. orderProductId: {
  91. type: [String, Number],
  92. default: ''
  93. },
  94. partnerId: {
  95. type: String,
  96. default: ''
  97. },
  98. recommendedUser: {
  99. type: Object,
  100. default: function () {
  101. return {}
  102. }
  103. }
  104. },
  105. data () {
  106. return {
  107. productInfo: {},
  108. booInvite: false,
  109. booCode: false,
  110. qrcode: null,
  111. codeUrl: '', // 二维码地址
  112. showCode: false, // 是否显示二维码弹窗
  113. booShareTip: false, // 分享朋友、朋友圈提示
  114. userShareConfig: {
  115. share: false, // 是否有权限分享(true是false无)
  116. id: '', // 用户ID
  117. userName: '', // 用户名称
  118. userImgUrl: '' // 用户头像
  119. }
  120. }
  121. },
  122. async mounted () {
  123. await this.$nextTick()
  124. if (!this.partnerId) {
  125. this.fetchUserShare()
  126. this.funGetProductDetail()
  127. } else {
  128. this.$router.replace({
  129. path: '/loan/apply/' + this.orderProductId,
  130. query: {
  131. partnerId: this.partnerId
  132. }
  133. })
  134. }
  135. },
  136. methods: {
  137. // 获取用户分享权限
  138. fetchUserShare () {
  139. getUserShare().then(res => {
  140. let shareHref = `${location.origin}${location.pathname}`
  141. if (res.status) {
  142. if (Object.prototype.toString.call(res.data) === '[object Object]') {
  143. this.userShareConfig = res.data
  144. }
  145. } else {
  146. Toast(res.msg)
  147. }
  148. if (this.partnerId) { // 合伙人
  149. shareHref += `?partnerId=${this.partnerId}`
  150. } else if (this.recommendedUser.id) { // 打开含有推荐人信息链接
  151. shareHref += `?recommendedUser=${encodeURIComponent(JSON.stringify(this.recommendedUser))}`
  152. } else if (Object.keys(this.userShareConfig).length) { // 默认本人打开、且有分享权限
  153. shareHref += `?recommendedUser=${encodeURIComponent(JSON.stringify(this.userShareConfig))}`
  154. }
  155. funWxShare('驼驼银服', '家里用钱,就找驼驼银服,省心,省力,妥妥的!', shareHref, location.protocol + '//api.tuotuoyinfu.com/img/logo.jpg')
  156. this.$nextTick(() => {
  157. this.createQRCode(shareHref)
  158. })
  159. }).catch(err => {
  160. Toast(err)
  161. })
  162. },
  163. funShowCode () {
  164. this.booInvite = false
  165. this.booCode = true
  166. },
  167. funGetProductDetail () {
  168. getProductDetail(this.orderProductId).then(res => {
  169. if (res.status) {
  170. this.productInfo = res.data
  171. this.$nextTick(() => {
  172. this.$refreshTitle(res.data.productName)
  173. })
  174. }
  175. })
  176. },
  177. createQRCode (link) {
  178. if (!this.qrcode) {
  179. this.qrcode = new QRCode('ttyf-qrcode', {
  180. width: 140,
  181. height: 140,
  182. text: link,
  183. colorDark: '#000',
  184. colorLight: '#fff'
  185. })
  186. } else {
  187. this.qrcode.clear()
  188. this.qrcode.makeCode(link)
  189. }
  190. this.codeUrl = ''
  191. setTimeout(() => {
  192. const canvas = document.getElementById('ttyf-qrcode').getElementsByTagName('canvas')[0]
  193. this.codeUrl = canvas.toDataURL('image/png', 1)
  194. }, 500)
  195. },
  196. funShareTip () {
  197. this.booShareTip = true
  198. this.booInvite = false
  199. }
  200. }
  201. }
  202. </script>
  203. <style lang="scss" scoped>
  204. .wrapper {
  205. width: 100%;
  206. min-height: 100vh;
  207. padding-bottom: 100px;
  208. background: #fff;
  209. }
  210. .banner {
  211. display: block;
  212. width: 100%;
  213. }
  214. .footer {
  215. position: fixed;
  216. left: 0;
  217. right: 0;
  218. bottom: 0;
  219. z-index: 99;
  220. width: 100%;
  221. padding: 14px 0;
  222. background: #FFFFFF;
  223. box-shadow: 0 -5px 10px 0 rgba(233, 234, 234, 1);
  224. &.myself {
  225. display: flex;
  226. justify-content: center;
  227. }
  228. &.other {
  229. display: flex;
  230. flex-direction: column;
  231. align-items: center;
  232. }
  233. }
  234. .btn-apply,
  235. .invite {
  236. height: 45px;
  237. border-radius: 4px;
  238. font-size: 14px;
  239. font-family: PingFangSC-Medium, PingFang SC;
  240. font-weight: 500;
  241. text-align: center;
  242. &.single {
  243. width: 326px;
  244. }
  245. &.double {
  246. width: 158px;
  247. }
  248. }
  249. .btn-apply {
  250. background: linear-gradient(180deg, #E0000B 0%, #CB0000 100%);
  251. color: #FFFFFF;
  252. line-height: 45px;
  253. }
  254. .invite {
  255. margin-left: 12px;
  256. border: 1px solid #CBB091;
  257. color: #C7AC8B;
  258. line-height: 45px;
  259. }
  260. .partner-info {
  261. display: flex;
  262. align-items: center;
  263. margin-top: 5px;
  264. .partner-avatar {
  265. width: 24px;
  266. height: 24px;
  267. border-radius: 50%;
  268. overflow: hidden;
  269. img {
  270. display: block;
  271. width: 100%;
  272. }
  273. }
  274. .name {
  275. font-size: 14px;
  276. color: #333333;
  277. line-height: 20px;
  278. }
  279. }
  280. .ttyf-van-popup-invite {
  281. width: 327px;
  282. padding-top: 26px;
  283. border-radius: 9px;
  284. .title {
  285. padding-left: 24px;
  286. font-size: 24px;
  287. font-family: PingFangSC-Medium, PingFang SC;
  288. font-weight: 500;
  289. color: #333333;
  290. line-height: 33px;
  291. }
  292. .tip {
  293. padding-left: 24px;
  294. margin-top: 4px;
  295. font-size: 16px;
  296. line-height: 22px;
  297. color: #666666;
  298. }
  299. .btns {
  300. display: flex;
  301. justify-content: center;
  302. align-items: center;
  303. margin-top: 28px;
  304. }
  305. a {
  306. width: 132px;
  307. height: 46px;
  308. border-radius: 4px;
  309. font-size: 14px;
  310. font-family: PingFangSC-Medium, PingFang SC;
  311. font-weight: 500;
  312. color: #FFFFFF;
  313. line-height: 46px;
  314. text-align: center;
  315. &:nth-of-type(1) {
  316. background: #5ACE8D;
  317. }
  318. &:nth-of-type(2) {
  319. margin-left: 16px;
  320. background: #FE9400;
  321. }
  322. }
  323. .show-code {
  324. font-size: 0;
  325. background: #FCFCFC;
  326. border-top: 1px solid #EBEBEB;
  327. padding: 17px 0 20px;
  328. margin-top: 16px;
  329. text-align: center;
  330. img {
  331. width: 20px;
  332. height: 20px;
  333. vertical-align: middle;
  334. }
  335. span {
  336. margin-left: 5px;
  337. font-size: 14px;
  338. color: #333333;
  339. line-height: 20px;
  340. vertical-align: middle;
  341. }
  342. }
  343. }
  344. .ttyf-van-popup-code {
  345. width: 252px;
  346. padding-bottom: 26px;
  347. border-radius: 9px;
  348. p {
  349. font-size: 24px;
  350. font-family: PingFangSC-Medium, PingFang SC;
  351. font-weight: 500;
  352. color: #333333;
  353. line-height: 33px;
  354. text-align: center;
  355. padding: 26px 0;
  356. border-bottom: 1px solid #EBEBEB;
  357. }
  358. .qrcode-wrap {
  359. width: 140px;
  360. height: 140px;
  361. margin: 12px auto 0;
  362. overflow: hidden;
  363. img {
  364. display: block;
  365. width: 100%;
  366. }
  367. }
  368. }
  369. .ttyf-van-popup-share {
  370. background: transparent;
  371. img {
  372. display: block;
  373. width: 100%;
  374. height: 286px;
  375. }
  376. }
  377. </style>