model.vue 17 KB

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