model.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826
  1. <template>
  2. <view class="content mone" v-if="baseURL">
  3. <model :modelId='mtype' :templateData='userTemplate' :isShare='isShare' :isLook='isLook' :isDefault='isDefault'
  4. :share-number='shareNumber'></model>
  5. <view class="fxmp flex bottom" v-if="type==2">
  6. <button class="share" type="default" open-type="share">
  7. 分享名片
  8. </button>
  9. <view class="nav-model" @click="navto('/pages/user/model/model?mtype=' + mtype+'&type=0')" v-if="mtype != 3">
  10. 生成我的名片
  11. </view>
  12. <view class="nav-model" @click="navto('/pages/user/model/modelrz?modelid='+userInfo.show_template_id)" v-if="mtype == 3 && hasLogin && userInfo.info_audit_status==-2">
  13. 立即认证
  14. </view>
  15. <view class="nav-model" @click="navto('/pages/user/model/mymodellist')" v-if="mtype == 3 && hasLogin && userInfo.info_audit_status==1">
  16. 查看我的名片
  17. </view>
  18. <view class="nav-model" v-if="mtype == 3 && hasLogin && userInfo.info_audit_status==0">
  19. 资料审核中
  20. </view>
  21. <view class="nav-model" v-if="mtype == 3 && !hasLogin" @click="toLogin">
  22. 生成我的名片
  23. </view>
  24. </view>
  25. <view class="fxmp flex bottom" v-if="type==3">
  26. <button class="share" type="default" open-type="share">
  27. 分享名片
  28. </button>
  29. <view class="nav-model " @click="navto('/pages/user/model/modelrz?type=1&modelid=' + mtype)">
  30. 修改名片
  31. </view>
  32. </view>
  33. <block v-if="type==0">
  34. <view class="ljrz bottom" v-if="userInfo.work_type_id <=0&&userInfo.info_audit_status != 1"
  35. @click="navto('/pages/user/model/modelrz?modelid=' + mtype + '&type=2')">
  36. 生成我的名片
  37. </view>
  38. <view v-else class="create-model flex bottom">
  39. <view class="price-show">
  40. 模板费用:<text>{{modelInfo.price*1}}</text>
  41. </view>
  42. <view class="to-show" @click="preview">
  43. 模板预览
  44. </view>
  45. <view class="by-now" @click="gobuy">
  46. 立即使用
  47. </view>
  48. </view>
  49. </block>
  50. <view class="yl bottom" v-if="previewShow" @click="outPreview">
  51. 结束预览
  52. </view>
  53. </view>
  54. </template>
  55. <script>
  56. import {
  57. mapState,
  58. mapMutations
  59. } from 'vuex';
  60. import {
  61. getUserCardInfo,
  62. getCommonUserCardInfo,
  63. getShowTemplateItem,
  64. subShowTemplateOrder
  65. } from '@/api/model.js'
  66. import {
  67. getUser
  68. } from '@/api/user.js';
  69. import {
  70. saveUrl,
  71. interceptor
  72. } from '@/utils/loginUtils.js';
  73. import model from '@/pages/modelData/index.vue';
  74. export default {
  75. components: {
  76. model
  77. },
  78. data() {
  79. return {
  80. mtype: 1, //modelid
  81. shareId: '', //保存分享uid
  82. // 默认显示数据
  83. cardInfo: {},
  84. // 是否显示默认
  85. isDefault: true,
  86. shareNumber: 0, //浏览量
  87. userTemplate: {}, //用户展示数据
  88. modelInfo: {}, //当前模板信息
  89. payType: 'wxpay',
  90. type: 0, //0为商品页面进入1为个人中心进入修改预览2为分享查看预览,3为已购模板进入查看分享
  91. isShare: false, //是否显示分享按钮
  92. isLook: 0, //1为平台浏览量2为用户浏览量0为不显示
  93. previewShow: false, //是否显示预览
  94. }
  95. },
  96. onLoad(opt) {
  97. // #ifndef MP
  98. if (opt.spread) {
  99. // 存储其他邀请人
  100. uni.setStorageSync('spread', opt.spread);
  101. }
  102. // #endif
  103. // #ifdef MP
  104. if (opt.scene) {
  105. // 存储小程序邀请人
  106. uni.setStorage({
  107. key: 'spread_code',
  108. data: opt.scene
  109. });
  110. }
  111. uni.hideShareMenu();
  112. // #endif
  113. // 获取模板id
  114. this.mtype = +opt.mtype
  115. // 获取查看类型
  116. this.type = +opt.type
  117. // 是否首页进入
  118. if (this.type === 0) {
  119. this.isLook = 1;
  120. this.getShowTemplateItem();
  121. if (this.userInfo.uid) {
  122. this.getCommonUserCardInfo(this.userInfo.uid);
  123. }
  124. return
  125. }
  126. //个人中心提交数据预览
  127. if (this.type === 1) {
  128. this.userTemplate = uni.getStorageSync('modeldata');
  129. this.isDefault = false;
  130. uni.setNavigationBarTitle({
  131. title: '名片预览'
  132. })
  133. return
  134. }
  135. //分享预览
  136. if (this.type === 2) {
  137. console.log(opt.type, 'opt.type');
  138. this.isLook = 2;
  139. this.shareId = opt.uid
  140. this.getCommonUserCardInfo(opt.uid);
  141. return
  142. }
  143. //我的模板页进入预览
  144. if (this.type === 3) {
  145. console.log(opt.type, 'opt.type');
  146. this.isShare = true;
  147. this.isLook = 2;
  148. this.shareId = this.userInfo.uid;
  149. this.getCommonUserCardInfo(this.userInfo.uid);
  150. return
  151. }
  152. // if(opt.look && opt.look == 2) {
  153. // this.islook = opt.look
  154. // this.cardInfo = uni.getStorageSync('modeldata')
  155. // this.is_yl = true
  156. // }else {
  157. // if (opt.look && opt.look == 1) {
  158. // uni.showShareMenu();
  159. // this.look = false
  160. // }
  161. // if (opt.uid) {
  162. // this.shareId = opt.uid
  163. // this.getCommonUserCardInfo(opt.uid)
  164. // } else {
  165. // this.getShowTemplateItem()
  166. // }
  167. // }
  168. },
  169. computed: {
  170. ...mapState(['baseURL']),
  171. ...mapState('user', ['userInfo','hasLogin']),
  172. },
  173. onShow() {
  174. // this.getUser()
  175. },
  176. // #ifdef MP
  177. onShareAppMessage(options) {
  178. // 设置菜单中的转发按钮触发转发事件时的转发内容
  179. let pages = getCurrentPages(); //获取加载的页面
  180. let currentPage = pages[pages.length - 1]; //获取当前页面的对象
  181. let url = currentPage.route; //当前页面url
  182. let item = currentPage.options; //如果要获取url中所带的参数可以查看options
  183. let shareObj = {}
  184. console.log(url, 'url');
  185. shareObj = {
  186. title: this.userTemplate.name + '母婴界数字名片', // 默认是小程序的名称(可以写slogan等)
  187. path: url + '?uid=' + this.shareId + '&mtype=' + this.mtype + '&type=2', // 默认是当前页面,必须是以‘/’开头的完整路径
  188. imageUrl: '',
  189. success: function(res) {
  190. // 转发成功之后的回调
  191. if (res.errMsg == 'shareAppMessage:ok') {}
  192. },
  193. fail: function() {
  194. // 转发失败之后的回调
  195. if (res.errMsg == 'shareAppMessage:fail cancel') {
  196. // 用户取消转发
  197. } else if (res.errMsg == 'shareAppMessage:fail') {
  198. // 转发失败,其中 detail message 为详细失败信息
  199. }
  200. }
  201. };
  202. console.log(shareObj)
  203. return shareObj;
  204. },
  205. // #endif
  206. onUnload() {
  207. let pages = getCurrentPages(); //获取加载的页面
  208. let currentPage = pages[pages.length - 2]; //获取当前页面的对象
  209. // console.log(currentPage.route)
  210. if (currentPage.route == 'pages/public/wxLogin') {
  211. uni.switchTab({
  212. url: '/pages/index/index'
  213. })
  214. }
  215. },
  216. methods: {
  217. ...mapMutations('user', ['setUserInfo']),
  218. toLogin() {
  219. saveUrl();
  220. interceptor();
  221. },
  222. // 模板预览
  223. preview() {
  224. if (!this.userInfo.uid) {
  225. uni.showModal({
  226. title: '提示',
  227. content: '您未登录是否登录查看',
  228. cancelText: '取消',
  229. confirmText: '立即登录',
  230. success: res => {
  231. if (res.confirm) {
  232. saveUrl();
  233. interceptor();
  234. }
  235. },
  236. fail: () => {},
  237. complete: () => {}
  238. });
  239. return
  240. }
  241. // 判断是否显示默认数据
  242. if (this.userTemplate.id) {
  243. this.isDefault = false;
  244. } else {
  245. this.isDefault = true;
  246. }
  247. this.previewShow = true;
  248. // 隐藏浏览数量
  249. this.isLook = 0;
  250. },
  251. // 结束预览
  252. outPreview() {
  253. // 显示默认数据
  254. this.isDefault = true;
  255. this.previewShow = false;
  256. if (this.type == 0) {
  257. this.isLook = 1;
  258. return
  259. }
  260. if (this.type == 3) {
  261. this.isLook = 2;
  262. return
  263. }
  264. },
  265. // 监听web视图反馈
  266. changeDate(base) {
  267. console.log(base, 'mss');
  268. },
  269. navto(url) {
  270. uni.navigateTo({
  271. url
  272. })
  273. },
  274. getUser() {
  275. const that = this;
  276. getUser({}).then((e) => {
  277. that.setUserInfo(e.data)
  278. if (e.data.work_type_id > 0 && that.shareId == '') {
  279. that.getUserCardInfo()
  280. } else {
  281. that.cardInfo = {}
  282. }
  283. }).catch((e) => {})
  284. },
  285. gobuy() {
  286. let that = this
  287. subShowTemplateOrder({
  288. id: that.mtype,
  289. pay_type: that.payType
  290. }).then(res => {
  291. if (res.data.status == 1) {
  292. uni.showModal({
  293. title: '提示',
  294. content: '支付成功!',
  295. cancelText: '关闭',
  296. confirmText: '查看模板',
  297. success: res => {
  298. if (res.confirm) {
  299. uni.reLaunch({
  300. url: '/pages/user/model/model?mtype=' +
  301. that.mtype,
  302. });
  303. }
  304. },
  305. fail: () => {},
  306. complete: () => {}
  307. });
  308. } else {
  309. let da = res.data.jsApiParameters;
  310. let data = {
  311. appId: da.appId,
  312. // #ifdef H5
  313. timestamp: da.timeStamp,
  314. // #endif
  315. // #ifdef MP
  316. timeStamp: da.timeStamp + '',
  317. // #endif
  318. nonceStr: da.nonceStr,
  319. package: da.package,
  320. signType: da.signType,
  321. paySign: da.paySign,
  322. success: function(res) {
  323. // obj.paySuccessTo();
  324. // alert('支付成功')
  325. uni.showModal({
  326. title: '提示',
  327. content: '支付成功!',
  328. cancelText: '关闭',
  329. confirmText: '查看模板',
  330. success: res => {
  331. if (res.confirm) {
  332. uni.reLaunch({
  333. url: '/pages/user/model/model?mtype=' +
  334. that.mtype,
  335. });
  336. }
  337. },
  338. fail: () => {},
  339. complete: () => {}
  340. });
  341. console.log('支付成功')
  342. },
  343. fail: (err) => {
  344. console.log(err)
  345. // alert('支付失败')
  346. // uni.navigateTo({
  347. // url: '/pages/order/order?state=0'
  348. // });
  349. }
  350. };
  351. console.log(data, 'timeStamp')
  352. if (that.payType == 'wxpay') {
  353. console.log('到这里')
  354. wx.requestPayment(data)
  355. }
  356. }
  357. })
  358. },
  359. // 获取模板详情
  360. getShowTemplateItem() {
  361. let that = this
  362. getShowTemplateItem({
  363. id: that.mtype
  364. }).then(res => {
  365. that.modelInfo = res.data;
  366. if (that.type == 0) {
  367. uni.setNavigationBarTitle({
  368. title: that.modelInfo.title
  369. })
  370. that.shareNumber = res.data.look_count
  371. }
  372. })
  373. },
  374. // 加载用户模板数据
  375. getCommonUserCardInfo(uid) {
  376. let that = this
  377. getCommonUserCardInfo({
  378. uid: uid
  379. }).then(res => {
  380. let arr = []
  381. let basearr = res.data.service_area_all
  382. basearr.forEach(item => {
  383. if(item.length == 3) {
  384. arr.push(item[0].name + item[1].name + item[2].name)
  385. }
  386. if(item.length == 2) {
  387. arr.push(item[0].name + item[1].name + '市辖区')
  388. }
  389. })
  390. res.data.service_area_all = arr
  391. // 保存用户模板数据
  392. that.userTemplate = res.data
  393. // 判断是否从用户个人中心或者分享进入
  394. if (that.type == 3 || that.type == 2) {
  395. // 修改为非默认数据
  396. that.isDefault = false;
  397. that.shareNumber = res.data.card_look_count;
  398. uni.setNavigationBarTitle({
  399. title: this.userTemplate.name + '的分享名片'
  400. })
  401. }
  402. })
  403. },
  404. getUserCardInfo() {
  405. let that = this
  406. getUserCardInfo().then(res => {
  407. console.log(res)
  408. let arr = []
  409. let basearr = res.data.service_area_all
  410. basearr.forEach(item => {
  411. arr.push(item[0].name + item[1].name + item[2].name)
  412. })
  413. res.data.service_area_all = arr
  414. that.cardInfo = res.data
  415. })
  416. }
  417. }
  418. }
  419. </script>
  420. <style lang="scss" scoped>
  421. .bottom_padding {
  422. height: 45px;
  423. width: 100%;
  424. }
  425. .m-card {
  426. width: 640rpx;
  427. background: #fcf4f1;
  428. border-radius: 20rpx;
  429. position: relative;
  430. // min-height: 270rpx;
  431. margin: 0 auto 46rpx;
  432. .card-tit {
  433. width: 219rpx;
  434. height: 57rpx;
  435. background: #F46C85;
  436. border-radius: 20rpx 28rpx 29rpx 0rpx;
  437. justify-content: flex-start;
  438. align-items: center;
  439. padding: 0 20rpx;
  440. font-size: 32rpx;
  441. font-weight: bold;
  442. color: #FFFFFF;
  443. .tit-logo {
  444. width: 32rpx;
  445. height: 32rpx;
  446. margin-right: 18rpx;
  447. }
  448. }
  449. .card-bg {
  450. width: 100%;
  451. height: 270rpx;
  452. position: absolute;
  453. bottom: 0rpx;
  454. }
  455. .card-content {
  456. padding: 25rpx 35rpx;
  457. font-size: 26rpx;
  458. font-weight: 500;
  459. color: #2C2E35;
  460. position: relative;
  461. }
  462. .img-list {
  463. justify-content: space-between;
  464. flex-wrap: wrap;
  465. margin: auto;
  466. padding: 30rpx 30rpx 0;
  467. position: relative;
  468. image {
  469. width: 270rpx;
  470. height: 270rpx;
  471. background-color: #fff;
  472. margin-bottom: 30rpx;
  473. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.6);
  474. }
  475. }
  476. .fw {
  477. font-size: 26rpx;
  478. font-weight: 500;
  479. color: #2C2E35;
  480. padding: 10rpx 0;
  481. .fw-tit {
  482. color: #F46C85;
  483. display: flex;
  484. align-items: center;
  485. .yg {
  486. background-color: #F46C85;
  487. display: inline-block;
  488. width: 10rpx;
  489. height: 10rpx;
  490. border-radius: 50%;
  491. margin-right: 10rpx;
  492. }
  493. }
  494. .fw-content {
  495. padding-top: 10rpx;
  496. padding-left: 18rpx;
  497. text-align: justify;
  498. }
  499. }
  500. .user-info {
  501. flex-wrap: wrap;
  502. font-size: 26rpx;
  503. font-weight: 500;
  504. color: #000000;
  505. position: relative;
  506. .info-item-b,
  507. .info-item-q {
  508. padding: 10rpx 0;
  509. color: #000000;
  510. position: relative;
  511. padding-left: 20rpx;
  512. &::before {
  513. display: inline-block;
  514. content: '';
  515. width: 10rpx;
  516. height: 10rpx;
  517. border-radius: 50%;
  518. background-color: #F46C85;
  519. position: absolute;
  520. top: 22rpx;
  521. left: 0;
  522. }
  523. .qianger {
  524. width: 2em;
  525. display: inline-block;
  526. }
  527. .laner {
  528. width: 0.5em;
  529. display: inline-block;
  530. }
  531. }
  532. .info-item-b {
  533. width: 50%;
  534. }
  535. .info-item-q {
  536. width: 100%;
  537. display: flex;
  538. align-items: flex-start;
  539. justify-content: start;
  540. .fwdz {
  541. flex-direction: column;
  542. align-items: flex-start;
  543. }
  544. .gzt {
  545. width: 312rpx;
  546. height: 24rpx;
  547. padding-top: 10rpx;
  548. position: relative;
  549. image {
  550. width: 312rpx;
  551. height: 24rpx;
  552. position: relative;
  553. }
  554. .gzt-price,
  555. .gzt-price-b {
  556. width: 200rpx;
  557. text-align: center;
  558. position: absolute;
  559. padding-top: 20rpx;
  560. &::after {
  561. content: '';
  562. width: 0px;
  563. height: 0rpx;
  564. // background: #FEB8C6;
  565. border: 14rpx solid;
  566. border-color: transparent transparent #FEB8C6;
  567. // border-top:transparent;
  568. // border-left: transparent;
  569. // border-right: transparent;
  570. position: absolute;
  571. top: -14rpx;
  572. left: 0;
  573. right: 0;
  574. margin: auto;
  575. }
  576. text {
  577. color: #F46C85;
  578. }
  579. }
  580. .gzt-price {
  581. left: -100rpx;
  582. }
  583. .gzt-price-b {
  584. right: -100rpx;
  585. }
  586. }
  587. .rz {
  588. margin-top: 10rpx;
  589. margin-left: 10rpx;
  590. width: 87rpx;
  591. height: 26rpx;
  592. }
  593. }
  594. }
  595. }
  596. .m-btm {
  597. width: 660rpx;
  598. height: 384rpx;
  599. }
  600. .hua2 {
  601. position: relative;
  602. &::before {
  603. content: '';
  604. width: 199rpx;
  605. height: 298rpx;
  606. background: url($base-url + '/resource/icon/model1/hua2.png') no-repeat;
  607. position: absolute;
  608. bottom: -100rpx;
  609. right: 0;
  610. background-size: 100% 100%;
  611. }
  612. }
  613. .hua3 {
  614. position: relative;
  615. &::before {
  616. content: '';
  617. width: 192rpx;
  618. height: 223rpx;
  619. background: url($base-url + '/resource/icon/model1/hua3.png') no-repeat;
  620. position: absolute;
  621. top: 0;
  622. bottom: 0;
  623. left: 0;
  624. margin: auto;
  625. background-size: 100% 100%;
  626. }
  627. }
  628. .hua4 {
  629. position: relative;
  630. &::before {
  631. content: '';
  632. width: 128rpx;
  633. height: 145rpx;
  634. background: url($base-url + '/resource/icon/model1/hua4.png') no-repeat;
  635. position: absolute;
  636. bottom: -70rpx;
  637. right: 0;
  638. background-size: 100% 100%;
  639. }
  640. }
  641. .hua5 {
  642. position: relative;
  643. &::before {
  644. content: '';
  645. width: 199rpx;
  646. height: 298rpx;
  647. background: url($base-url + '/resource/icon/model1/hua2.png') no-repeat;
  648. position: absolute;
  649. bottom: -100rpx;
  650. left: 0;
  651. background-size: 100% 100%;
  652. transform: rotateY(180deg);
  653. }
  654. }
  655. .hua6 {
  656. position: relative;
  657. &::before {
  658. content: '';
  659. width: 192rpx;
  660. height: 223rpx;
  661. background: url($base-url + '/resource/icon/model1/hua3.png') no-repeat;
  662. position: absolute;
  663. bottom: -110rpx;
  664. right: 0;
  665. background-size: 100% 100%;
  666. transform: rotateY(180deg);
  667. }
  668. }
  669. .fxmp {
  670. width: 750rpx;
  671. .share {
  672. width: 50%;
  673. padding: 0;
  674. border-radius: 0;
  675. flex-grow: 1;
  676. background-color: $base-color;
  677. color: #fff;
  678. font-size: 32rpx;
  679. &::after {
  680. border: none;
  681. }
  682. }
  683. .nav-model {
  684. background-color: #FFF;
  685. color: $base-color;
  686. width: 50%;
  687. }
  688. }
  689. .fxmp {
  690. position: fixed;
  691. width: 750rpx;
  692. bottom: 0;
  693. padding: 0;
  694. background: #f65486;
  695. // border-radius: 5rpx;
  696. font-size: 30rpx;
  697. font-weight: 500;
  698. color: #FFFFFF;
  699. text-align: center;
  700. }
  701. .create-model {
  702. position: fixed;
  703. width: 750rpx;
  704. bottom: 0;
  705. // border-radius: 5rpx;
  706. font-size: 32rpx;
  707. font-weight: 500;
  708. text-align: center;
  709. .price-show {
  710. font-size: 32rpx;
  711. font-weight: 500;
  712. color: #333333;
  713. background-color: #fff;
  714. flex-grow: 1;
  715. text {
  716. font-size: 48rpx;
  717. font-weight: 500;
  718. color: #FC6F6D;
  719. }
  720. }
  721. .to-show,
  722. .by-now {
  723. width: 223rpx;
  724. background: #fa98b6;
  725. flex-shrink: 0;
  726. font-size: 34rpx;
  727. color: #fff;
  728. }
  729. .by-now {
  730. background: #f65486;
  731. }
  732. }
  733. .yl {
  734. position: fixed;
  735. bottom: 0;
  736. width: 750rpx;
  737. font-size: 32rpx;
  738. font-weight: 500;
  739. text-align: center;
  740. color: #fff;
  741. text-align: center;
  742. font-size: 34rpx;
  743. background-color: #f65486;
  744. }
  745. .ljrz {
  746. position: fixed;
  747. width: 750rpx;
  748. bottom: 0;
  749. font-size: 32rpx;
  750. font-weight: 500;
  751. text-align: center;
  752. background-color: #f65486;
  753. color: #fff;
  754. }
  755. .bottom {
  756. line-height: 45px;
  757. height: 45px;
  758. }
  759. </style>