model.vue 17 KB

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