123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826 |
- <template>
- <view class="content mone" v-if="baseURL">
- <model :modelId='mtype' :templateData='userTemplate' :isShare='isShare' :isLook='isLook' :isDefault='isDefault'
- :share-number='shareNumber'></model>
- <view class="fxmp flex bottom" v-if="type==2">
- <button class="share" type="default" open-type="share">
- 分享名片
- </button>
- <view class="nav-model" @click="navto('/pages/user/model/model?mtype=' + mtype+'&type=0')" v-if="mtype != 3">
- 生成我的名片
- </view>
- <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">
- 立即认证
- </view>
- <view class="nav-model" @click="navto('/pages/user/model/mymodellist')" v-if="mtype == 3 && hasLogin && userInfo.info_audit_status==1">
- 查看我的名片
- </view>
- <view class="nav-model" v-if="mtype == 3 && hasLogin && userInfo.info_audit_status==0">
- 资料审核中
- </view>
- <view class="nav-model" v-if="mtype == 3 && !hasLogin" @click="toLogin">
- 生成我的名片
- </view>
- </view>
- <view class="fxmp flex bottom" v-if="type==3">
- <button class="share" type="default" open-type="share">
- 分享名片
- </button>
- <view class="nav-model " @click="navto('/pages/user/model/modelrz?type=1&modelid=' + mtype)">
- 修改名片
- </view>
- </view>
- <block v-if="type==0">
- <view class="ljrz bottom" v-if="userInfo.work_type_id <=0&&userInfo.info_audit_status != 1"
- @click="navto('/pages/user/model/modelrz?modelid=' + mtype + '&type=2')">
- 生成我的名片
- </view>
- <view v-else class="create-model flex bottom">
- <view class="price-show">
- 模板费用:<text>{{modelInfo.price*1}}</text>
- </view>
- <view class="to-show" @click="preview">
- 模板预览
- </view>
- <view class="by-now" @click="gobuy">
- 立即使用
- </view>
- </view>
- </block>
- <view class="yl bottom" v-if="previewShow" @click="outPreview">
- 结束预览
- </view>
- </view>
- </template>
- <script>
- import {
- mapState,
- mapMutations
- } from 'vuex';
- import {
- getUserCardInfo,
- getCommonUserCardInfo,
- getShowTemplateItem,
- subShowTemplateOrder
- } from '@/api/model.js'
- import {
- getUser
- } from '@/api/user.js';
- import {
- saveUrl,
- interceptor
- } from '@/utils/loginUtils.js';
- import model from '@/pages/modelData/index.vue';
- export default {
- components: {
- model
- },
- data() {
- return {
- mtype: 1, //modelid
- shareId: '', //保存分享uid
- // 默认显示数据
- cardInfo: {},
- // 是否显示默认
- isDefault: true,
- shareNumber: 0, //浏览量
- userTemplate: {}, //用户展示数据
- modelInfo: {}, //当前模板信息
- payType: 'wxpay',
- type: 0, //0为商品页面进入1为个人中心进入修改预览2为分享查看预览,3为已购模板进入查看分享
- isShare: false, //是否显示分享按钮
- isLook: 0, //1为平台浏览量2为用户浏览量0为不显示
- previewShow: false, //是否显示预览
- }
- },
- onLoad(opt) {
- // #ifndef MP
- if (opt.spread) {
- // 存储其他邀请人
- uni.setStorageSync('spread', opt.spread);
- }
- // #endif
- // #ifdef MP
- if (opt.scene) {
- // 存储小程序邀请人
- uni.setStorage({
- key: 'spread_code',
- data: opt.scene
- });
- }
- uni.hideShareMenu();
- // #endif
- // 获取模板id
- this.mtype = +opt.mtype
- // 获取查看类型
- this.type = +opt.type
- // 是否首页进入
- if (this.type === 0) {
- this.isLook = 1;
- this.getShowTemplateItem();
- if (this.userInfo.uid) {
- this.getCommonUserCardInfo(this.userInfo.uid);
- }
- return
- }
- //个人中心提交数据预览
- if (this.type === 1) {
- this.userTemplate = uni.getStorageSync('modeldata');
- this.isDefault = false;
- uni.setNavigationBarTitle({
- title: '名片预览'
- })
- return
- }
- //分享预览
- if (this.type === 2) {
- console.log(opt.type, 'opt.type');
- this.isLook = 2;
- this.shareId = opt.uid
- this.getCommonUserCardInfo(opt.uid);
- return
- }
- //我的模板页进入预览
- if (this.type === 3) {
- console.log(opt.type, 'opt.type');
- this.isShare = true;
- this.isLook = 2;
- this.shareId = this.userInfo.uid;
- this.getCommonUserCardInfo(this.userInfo.uid);
- return
- }
- // if(opt.look && opt.look == 2) {
- // this.islook = opt.look
- // this.cardInfo = uni.getStorageSync('modeldata')
- // this.is_yl = true
- // }else {
- // if (opt.look && opt.look == 1) {
- // uni.showShareMenu();
- // this.look = false
- // }
- // if (opt.uid) {
- // this.shareId = opt.uid
- // this.getCommonUserCardInfo(opt.uid)
- // } else {
- // this.getShowTemplateItem()
- // }
- // }
- },
- computed: {
- ...mapState(['baseURL']),
- ...mapState('user', ['userInfo','hasLogin']),
- },
- onShow() {
- // this.getUser()
- },
- // #ifdef MP
- onShareAppMessage(options) {
- // 设置菜单中的转发按钮触发转发事件时的转发内容
- let pages = getCurrentPages(); //获取加载的页面
- let currentPage = pages[pages.length - 1]; //获取当前页面的对象
- let url = currentPage.route; //当前页面url
- let item = currentPage.options; //如果要获取url中所带的参数可以查看options
- let shareObj = {}
- console.log(url, 'url');
- shareObj = {
- title: this.userTemplate.name + '母婴界数字名片', // 默认是小程序的名称(可以写slogan等)
- path: url + '?uid=' + this.shareId + '&mtype=' + this.mtype + '&type=2', // 默认是当前页面,必须是以‘/’开头的完整路径
- imageUrl: '',
- success: function(res) {
- // 转发成功之后的回调
- if (res.errMsg == 'shareAppMessage:ok') {}
- },
- fail: function() {
- // 转发失败之后的回调
- if (res.errMsg == 'shareAppMessage:fail cancel') {
- // 用户取消转发
- } else if (res.errMsg == 'shareAppMessage:fail') {
- // 转发失败,其中 detail message 为详细失败信息
- }
- }
- };
- console.log(shareObj)
- return shareObj;
- },
- // #endif
- onUnload() {
- let pages = getCurrentPages(); //获取加载的页面
- let currentPage = pages[pages.length - 2]; //获取当前页面的对象
- // console.log(currentPage.route)
- if (currentPage.route == 'pages/public/wxLogin') {
- uni.switchTab({
- url: '/pages/index/index'
- })
- }
- },
- methods: {
- ...mapMutations('user', ['setUserInfo']),
- toLogin() {
- saveUrl();
- interceptor();
- },
- // 模板预览
- preview() {
- if (!this.userInfo.uid) {
- uni.showModal({
- title: '提示',
- content: '您未登录是否登录查看',
- cancelText: '取消',
- confirmText: '立即登录',
- success: res => {
- if (res.confirm) {
- saveUrl();
- interceptor();
- }
- },
- fail: () => {},
- complete: () => {}
- });
- return
- }
- // 判断是否显示默认数据
- if (this.userTemplate.id) {
- this.isDefault = false;
- } else {
- this.isDefault = true;
- }
- this.previewShow = true;
- // 隐藏浏览数量
- this.isLook = 0;
- },
- // 结束预览
- outPreview() {
- // 显示默认数据
- this.isDefault = true;
- this.previewShow = false;
- if (this.type == 0) {
- this.isLook = 1;
- return
- }
- if (this.type == 3) {
- this.isLook = 2;
- return
- }
- },
- // 监听web视图反馈
- changeDate(base) {
- console.log(base, 'mss');
- },
- navto(url) {
- uni.navigateTo({
- url
- })
- },
- getUser() {
- const that = this;
- getUser({}).then((e) => {
- that.setUserInfo(e.data)
- if (e.data.work_type_id > 0 && that.shareId == '') {
- that.getUserCardInfo()
- } else {
- that.cardInfo = {}
- }
- }).catch((e) => {})
- },
- gobuy() {
- let that = this
- subShowTemplateOrder({
- id: that.mtype,
- pay_type: that.payType
- }).then(res => {
- if (res.data.status == 1) {
- uni.showModal({
- title: '提示',
- content: '支付成功!',
- cancelText: '关闭',
- confirmText: '查看模板',
- success: res => {
- if (res.confirm) {
- uni.reLaunch({
- url: '/pages/user/model/model?mtype=' +
- that.mtype,
- });
- }
- },
- fail: () => {},
- complete: () => {}
- });
- } else {
- let da = res.data.jsApiParameters;
- let data = {
- appId: da.appId,
- // #ifdef H5
- timestamp: da.timeStamp,
- // #endif
- // #ifdef MP
- timeStamp: da.timeStamp + '',
- // #endif
- nonceStr: da.nonceStr,
- package: da.package,
- signType: da.signType,
- paySign: da.paySign,
- success: function(res) {
- // obj.paySuccessTo();
- // alert('支付成功')
- uni.showModal({
- title: '提示',
- content: '支付成功!',
- cancelText: '关闭',
- confirmText: '查看模板',
- success: res => {
- if (res.confirm) {
- uni.reLaunch({
- url: '/pages/user/model/model?mtype=' +
- that.mtype,
- });
- }
- },
- fail: () => {},
- complete: () => {}
- });
- console.log('支付成功')
- },
- fail: (err) => {
- console.log(err)
- // alert('支付失败')
- // uni.navigateTo({
- // url: '/pages/order/order?state=0'
- // });
- }
- };
- console.log(data, 'timeStamp')
- if (that.payType == 'wxpay') {
- console.log('到这里')
- wx.requestPayment(data)
- }
- }
- })
- },
- // 获取模板详情
- getShowTemplateItem() {
- let that = this
- getShowTemplateItem({
- id: that.mtype
- }).then(res => {
- that.modelInfo = res.data;
- if (that.type == 0) {
- uni.setNavigationBarTitle({
- title: that.modelInfo.title
- })
- that.shareNumber = res.data.look_count
- }
- })
- },
- // 加载用户模板数据
- getCommonUserCardInfo(uid) {
- let that = this
- getCommonUserCardInfo({
- uid: uid
- }).then(res => {
- let arr = []
- let basearr = res.data.service_area_all
- basearr.forEach(item => {
- if(item.length == 3) {
- arr.push(item[0].name + item[1].name + item[2].name)
- }
- if(item.length == 2) {
- arr.push(item[0].name + item[1].name + '市辖区')
- }
- })
- res.data.service_area_all = arr
- // 保存用户模板数据
- that.userTemplate = res.data
- // 判断是否从用户个人中心或者分享进入
- if (that.type == 3 || that.type == 2) {
- // 修改为非默认数据
- that.isDefault = false;
- that.shareNumber = res.data.card_look_count;
- uni.setNavigationBarTitle({
- title: this.userTemplate.name + '的分享名片'
- })
- }
- })
- },
- getUserCardInfo() {
- let that = this
- getUserCardInfo().then(res => {
- console.log(res)
- let arr = []
- let basearr = res.data.service_area_all
- basearr.forEach(item => {
- arr.push(item[0].name + item[1].name + item[2].name)
- })
- res.data.service_area_all = arr
- that.cardInfo = res.data
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .bottom_padding {
- height: 45px;
- width: 100%;
- }
- .m-card {
- width: 640rpx;
- background: #fcf4f1;
- border-radius: 20rpx;
- position: relative;
- // min-height: 270rpx;
- margin: 0 auto 46rpx;
- .card-tit {
- width: 219rpx;
- height: 57rpx;
- background: #F46C85;
- border-radius: 20rpx 28rpx 29rpx 0rpx;
- justify-content: flex-start;
- align-items: center;
- padding: 0 20rpx;
- font-size: 32rpx;
- font-weight: bold;
- color: #FFFFFF;
- .tit-logo {
- width: 32rpx;
- height: 32rpx;
- margin-right: 18rpx;
- }
- }
- .card-bg {
- width: 100%;
- height: 270rpx;
- position: absolute;
- bottom: 0rpx;
- }
- .card-content {
- padding: 25rpx 35rpx;
- font-size: 26rpx;
- font-weight: 500;
- color: #2C2E35;
- position: relative;
- }
- .img-list {
- justify-content: space-between;
- flex-wrap: wrap;
- margin: auto;
- padding: 30rpx 30rpx 0;
- position: relative;
- image {
- width: 270rpx;
- height: 270rpx;
- background-color: #fff;
- margin-bottom: 30rpx;
- box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.6);
- }
- }
- .fw {
- font-size: 26rpx;
- font-weight: 500;
- color: #2C2E35;
- padding: 10rpx 0;
- .fw-tit {
- color: #F46C85;
- display: flex;
- align-items: center;
- .yg {
- background-color: #F46C85;
- display: inline-block;
- width: 10rpx;
- height: 10rpx;
- border-radius: 50%;
- margin-right: 10rpx;
- }
- }
- .fw-content {
- padding-top: 10rpx;
- padding-left: 18rpx;
- text-align: justify;
- }
- }
- .user-info {
- flex-wrap: wrap;
- font-size: 26rpx;
- font-weight: 500;
- color: #000000;
- position: relative;
- .info-item-b,
- .info-item-q {
- padding: 10rpx 0;
- color: #000000;
- position: relative;
- padding-left: 20rpx;
- &::before {
- display: inline-block;
- content: '';
- width: 10rpx;
- height: 10rpx;
- border-radius: 50%;
- background-color: #F46C85;
- position: absolute;
- top: 22rpx;
- left: 0;
- }
- .qianger {
- width: 2em;
- display: inline-block;
- }
- .laner {
- width: 0.5em;
- display: inline-block;
- }
- }
- .info-item-b {
- width: 50%;
- }
- .info-item-q {
- width: 100%;
- display: flex;
- align-items: flex-start;
- justify-content: start;
- .fwdz {
- flex-direction: column;
- align-items: flex-start;
- }
- .gzt {
- width: 312rpx;
- height: 24rpx;
- padding-top: 10rpx;
- position: relative;
- image {
- width: 312rpx;
- height: 24rpx;
- position: relative;
- }
- .gzt-price,
- .gzt-price-b {
- width: 200rpx;
- text-align: center;
- position: absolute;
- padding-top: 20rpx;
- &::after {
- content: '';
- width: 0px;
- height: 0rpx;
- // background: #FEB8C6;
- border: 14rpx solid;
- border-color: transparent transparent #FEB8C6;
- // border-top:transparent;
- // border-left: transparent;
- // border-right: transparent;
- position: absolute;
- top: -14rpx;
- left: 0;
- right: 0;
- margin: auto;
- }
- text {
- color: #F46C85;
- }
- }
- .gzt-price {
- left: -100rpx;
- }
- .gzt-price-b {
- right: -100rpx;
- }
- }
- .rz {
- margin-top: 10rpx;
- margin-left: 10rpx;
- width: 87rpx;
- height: 26rpx;
- }
- }
- }
- }
- .m-btm {
- width: 660rpx;
- height: 384rpx;
- }
- .hua2 {
- position: relative;
- &::before {
- content: '';
- width: 199rpx;
- height: 298rpx;
- background: url($base-url + '/resource/icon/model1/hua2.png') no-repeat;
- position: absolute;
- bottom: -100rpx;
- right: 0;
- background-size: 100% 100%;
- }
- }
- .hua3 {
- position: relative;
- &::before {
- content: '';
- width: 192rpx;
- height: 223rpx;
- background: url($base-url + '/resource/icon/model1/hua3.png') no-repeat;
- position: absolute;
- top: 0;
- bottom: 0;
- left: 0;
- margin: auto;
- background-size: 100% 100%;
- }
- }
- .hua4 {
- position: relative;
- &::before {
- content: '';
- width: 128rpx;
- height: 145rpx;
- background: url($base-url + '/resource/icon/model1/hua4.png') no-repeat;
- position: absolute;
- bottom: -70rpx;
- right: 0;
- background-size: 100% 100%;
- }
- }
- .hua5 {
- position: relative;
- &::before {
- content: '';
- width: 199rpx;
- height: 298rpx;
- background: url($base-url + '/resource/icon/model1/hua2.png') no-repeat;
- position: absolute;
- bottom: -100rpx;
- left: 0;
- background-size: 100% 100%;
- transform: rotateY(180deg);
- }
- }
- .hua6 {
- position: relative;
- &::before {
- content: '';
- width: 192rpx;
- height: 223rpx;
- background: url($base-url + '/resource/icon/model1/hua3.png') no-repeat;
- position: absolute;
- bottom: -110rpx;
- right: 0;
- background-size: 100% 100%;
- transform: rotateY(180deg);
- }
- }
- .fxmp {
- width: 750rpx;
- .share {
- width: 50%;
- padding: 0;
- border-radius: 0;
- flex-grow: 1;
- background-color: $base-color;
- color: #fff;
- font-size: 32rpx;
- &::after {
- border: none;
- }
- }
- .nav-model {
- background-color: #FFF;
- color: $base-color;
- width: 50%;
- }
- }
- .fxmp {
- position: fixed;
- width: 750rpx;
- bottom: 0;
- padding: 0;
- background: #f65486;
- // border-radius: 5rpx;
- font-size: 30rpx;
- font-weight: 500;
- color: #FFFFFF;
- text-align: center;
- }
- .create-model {
- position: fixed;
- width: 750rpx;
- bottom: 0;
- // border-radius: 5rpx;
- font-size: 32rpx;
- font-weight: 500;
- text-align: center;
- .price-show {
- font-size: 32rpx;
- font-weight: 500;
- color: #333333;
- background-color: #fff;
- flex-grow: 1;
- text {
- font-size: 48rpx;
- font-weight: 500;
- color: #FC6F6D;
- }
- }
- .to-show,
- .by-now {
- width: 223rpx;
- background: #fa98b6;
- flex-shrink: 0;
- font-size: 34rpx;
- color: #fff;
- }
- .by-now {
- background: #f65486;
- }
- }
- .yl {
- position: fixed;
- bottom: 0;
- width: 750rpx;
- font-size: 32rpx;
- font-weight: 500;
- text-align: center;
- color: #fff;
- text-align: center;
- font-size: 34rpx;
- background-color: #f65486;
- }
- .ljrz {
- position: fixed;
- width: 750rpx;
- bottom: 0;
- font-size: 32rpx;
- font-weight: 500;
- text-align: center;
- background-color: #f65486;
- color: #fff;
- }
- .bottom {
- line-height: 45px;
- height: 45px;
- }
- </style>
|