model.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823
  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"
  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. })
  387. res.data.service_area_all = arr
  388. // 保存用户模板数据
  389. that.userTemplate = res.data
  390. // 判断是否从用户个人中心或者分享进入
  391. if (that.type == 3 || that.type == 2) {
  392. // 修改为非默认数据
  393. that.isDefault = false;
  394. that.shareNumber = res.data.card_look_count;
  395. uni.setNavigationBarTitle({
  396. title: this.userTemplate.name + '的分享名片'
  397. })
  398. }
  399. })
  400. },
  401. getUserCardInfo() {
  402. let that = this
  403. getUserCardInfo().then(res => {
  404. console.log(res)
  405. let arr = []
  406. let basearr = res.data.service_area_all
  407. basearr.forEach(item => {
  408. arr.push(item[0].name + item[1].name + item[2].name)
  409. })
  410. res.data.service_area_all = arr
  411. that.cardInfo = res.data
  412. })
  413. }
  414. }
  415. }
  416. </script>
  417. <style lang="scss" scoped>
  418. .bottom_padding {
  419. height: 45px;
  420. width: 100%;
  421. }
  422. .m-card {
  423. width: 640rpx;
  424. background: #fcf4f1;
  425. border-radius: 20rpx;
  426. position: relative;
  427. // min-height: 270rpx;
  428. margin: 0 auto 46rpx;
  429. .card-tit {
  430. width: 219rpx;
  431. height: 57rpx;
  432. background: #F46C85;
  433. border-radius: 20rpx 28rpx 29rpx 0rpx;
  434. justify-content: flex-start;
  435. align-items: center;
  436. padding: 0 20rpx;
  437. font-size: 32rpx;
  438. font-weight: bold;
  439. color: #FFFFFF;
  440. .tit-logo {
  441. width: 32rpx;
  442. height: 32rpx;
  443. margin-right: 18rpx;
  444. }
  445. }
  446. .card-bg {
  447. width: 100%;
  448. height: 270rpx;
  449. position: absolute;
  450. bottom: 0rpx;
  451. }
  452. .card-content {
  453. padding: 25rpx 35rpx;
  454. font-size: 26rpx;
  455. font-weight: 500;
  456. color: #2C2E35;
  457. position: relative;
  458. }
  459. .img-list {
  460. justify-content: space-between;
  461. flex-wrap: wrap;
  462. margin: auto;
  463. padding: 30rpx 30rpx 0;
  464. position: relative;
  465. image {
  466. width: 270rpx;
  467. height: 270rpx;
  468. background-color: #fff;
  469. margin-bottom: 30rpx;
  470. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.6);
  471. }
  472. }
  473. .fw {
  474. font-size: 26rpx;
  475. font-weight: 500;
  476. color: #2C2E35;
  477. padding: 10rpx 0;
  478. .fw-tit {
  479. color: #F46C85;
  480. display: flex;
  481. align-items: center;
  482. .yg {
  483. background-color: #F46C85;
  484. display: inline-block;
  485. width: 10rpx;
  486. height: 10rpx;
  487. border-radius: 50%;
  488. margin-right: 10rpx;
  489. }
  490. }
  491. .fw-content {
  492. padding-top: 10rpx;
  493. padding-left: 18rpx;
  494. text-align: justify;
  495. }
  496. }
  497. .user-info {
  498. flex-wrap: wrap;
  499. font-size: 26rpx;
  500. font-weight: 500;
  501. color: #000000;
  502. position: relative;
  503. .info-item-b,
  504. .info-item-q {
  505. padding: 10rpx 0;
  506. color: #000000;
  507. position: relative;
  508. padding-left: 20rpx;
  509. &::before {
  510. display: inline-block;
  511. content: '';
  512. width: 10rpx;
  513. height: 10rpx;
  514. border-radius: 50%;
  515. background-color: #F46C85;
  516. position: absolute;
  517. top: 22rpx;
  518. left: 0;
  519. }
  520. .qianger {
  521. width: 2em;
  522. display: inline-block;
  523. }
  524. .laner {
  525. width: 0.5em;
  526. display: inline-block;
  527. }
  528. }
  529. .info-item-b {
  530. width: 50%;
  531. }
  532. .info-item-q {
  533. width: 100%;
  534. display: flex;
  535. align-items: flex-start;
  536. justify-content: start;
  537. .fwdz {
  538. flex-direction: column;
  539. align-items: flex-start;
  540. }
  541. .gzt {
  542. width: 312rpx;
  543. height: 24rpx;
  544. padding-top: 10rpx;
  545. position: relative;
  546. image {
  547. width: 312rpx;
  548. height: 24rpx;
  549. position: relative;
  550. }
  551. .gzt-price,
  552. .gzt-price-b {
  553. width: 200rpx;
  554. text-align: center;
  555. position: absolute;
  556. padding-top: 20rpx;
  557. &::after {
  558. content: '';
  559. width: 0px;
  560. height: 0rpx;
  561. // background: #FEB8C6;
  562. border: 14rpx solid;
  563. border-color: transparent transparent #FEB8C6;
  564. // border-top:transparent;
  565. // border-left: transparent;
  566. // border-right: transparent;
  567. position: absolute;
  568. top: -14rpx;
  569. left: 0;
  570. right: 0;
  571. margin: auto;
  572. }
  573. text {
  574. color: #F46C85;
  575. }
  576. }
  577. .gzt-price {
  578. left: -100rpx;
  579. }
  580. .gzt-price-b {
  581. right: -100rpx;
  582. }
  583. }
  584. .rz {
  585. margin-top: 10rpx;
  586. margin-left: 10rpx;
  587. width: 87rpx;
  588. height: 26rpx;
  589. }
  590. }
  591. }
  592. }
  593. .m-btm {
  594. width: 660rpx;
  595. height: 384rpx;
  596. }
  597. .hua2 {
  598. position: relative;
  599. &::before {
  600. content: '';
  601. width: 199rpx;
  602. height: 298rpx;
  603. background: url($base-url + '/resource/icon/model1/hua2.png') no-repeat;
  604. position: absolute;
  605. bottom: -100rpx;
  606. right: 0;
  607. background-size: 100% 100%;
  608. }
  609. }
  610. .hua3 {
  611. position: relative;
  612. &::before {
  613. content: '';
  614. width: 192rpx;
  615. height: 223rpx;
  616. background: url($base-url + '/resource/icon/model1/hua3.png') no-repeat;
  617. position: absolute;
  618. top: 0;
  619. bottom: 0;
  620. left: 0;
  621. margin: auto;
  622. background-size: 100% 100%;
  623. }
  624. }
  625. .hua4 {
  626. position: relative;
  627. &::before {
  628. content: '';
  629. width: 128rpx;
  630. height: 145rpx;
  631. background: url($base-url + '/resource/icon/model1/hua4.png') no-repeat;
  632. position: absolute;
  633. bottom: -70rpx;
  634. right: 0;
  635. background-size: 100% 100%;
  636. }
  637. }
  638. .hua5 {
  639. position: relative;
  640. &::before {
  641. content: '';
  642. width: 199rpx;
  643. height: 298rpx;
  644. background: url($base-url + '/resource/icon/model1/hua2.png') no-repeat;
  645. position: absolute;
  646. bottom: -100rpx;
  647. left: 0;
  648. background-size: 100% 100%;
  649. transform: rotateY(180deg);
  650. }
  651. }
  652. .hua6 {
  653. position: relative;
  654. &::before {
  655. content: '';
  656. width: 192rpx;
  657. height: 223rpx;
  658. background: url($base-url + '/resource/icon/model1/hua3.png') no-repeat;
  659. position: absolute;
  660. bottom: -110rpx;
  661. right: 0;
  662. background-size: 100% 100%;
  663. transform: rotateY(180deg);
  664. }
  665. }
  666. .fxmp {
  667. width: 750rpx;
  668. .share {
  669. width: 50%;
  670. padding: 0;
  671. border-radius: 0;
  672. flex-grow: 1;
  673. background-color: $base-color;
  674. color: #fff;
  675. font-size: 32rpx;
  676. &::after {
  677. border: none;
  678. }
  679. }
  680. .nav-model {
  681. background-color: #FFF;
  682. color: $base-color;
  683. width: 50%;
  684. }
  685. }
  686. .fxmp {
  687. position: fixed;
  688. width: 750rpx;
  689. bottom: 0;
  690. padding: 0;
  691. background: #f65486;
  692. // border-radius: 5rpx;
  693. font-size: 30rpx;
  694. font-weight: 500;
  695. color: #FFFFFF;
  696. text-align: center;
  697. }
  698. .create-model {
  699. position: fixed;
  700. width: 750rpx;
  701. bottom: 0;
  702. // border-radius: 5rpx;
  703. font-size: 32rpx;
  704. font-weight: 500;
  705. text-align: center;
  706. .price-show {
  707. font-size: 32rpx;
  708. font-weight: 500;
  709. color: #333333;
  710. background-color: #fff;
  711. flex-grow: 1;
  712. text {
  713. font-size: 48rpx;
  714. font-weight: 500;
  715. color: #FC6F6D;
  716. }
  717. }
  718. .to-show,
  719. .by-now {
  720. width: 223rpx;
  721. background: #fa98b6;
  722. flex-shrink: 0;
  723. font-size: 34rpx;
  724. color: #fff;
  725. }
  726. .by-now {
  727. background: #f65486;
  728. }
  729. }
  730. .yl {
  731. position: fixed;
  732. bottom: 0;
  733. width: 750rpx;
  734. font-size: 32rpx;
  735. font-weight: 500;
  736. text-align: center;
  737. color: #fff;
  738. text-align: center;
  739. font-size: 34rpx;
  740. background-color: #f65486;
  741. }
  742. .ljrz {
  743. position: fixed;
  744. width: 750rpx;
  745. bottom: 0;
  746. font-size: 32rpx;
  747. font-weight: 500;
  748. text-align: center;
  749. background-color: #f65486;
  750. color: #fff;
  751. }
  752. .bottom {
  753. line-height: 45px;
  754. height: 45px;
  755. }
  756. </style>