123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- <template>
- <view style="display: flex;justify-content: center;">
- <view class="wx_code">
- <view class="wx_code_name">
- <view class="ellipsis">{{ enterpriseInfo.enterpriseName }}</view>
- <view class="user-name">{{ userInfo.name }}</view>
- </view>
- <view class="wx_code_scan"><image :src="QrSrc" mode="aspectFit" /></view>
- <view class="wx_code_tips"><text>扫一扫,立即使用小程序商城</text></view>
- </view>
- <view class="save-btn" @click="downloadFile">保存小程序码</view>
- </view>
- </template>
- <script>
- import webUrl from '../../common/config.js';
- export default {
- data() {
- return {
- QrSrc: ''
- };
- },
- computed: {
- userInfo() {
- return this.$store.state.userInfo;
- },
- enterpriseInfo() {
- return this.$store.state.enterprise;
- }
- },
- onLoad() {
- this.createwxaqrcode();
- },
- methods: {
- async createwxaqrcode() {
- let pathS = 'pages/index/index';
- this.$u.api
- .createwxaqrcode({
- path: pathS,
- params: this.userInfo.staffId + '_'
- })
- .then(res => {
- this.QrSrc = res.data.indexOf('https') > -1 ? res.data : webUrl.QRC_SRC + res.data;
- });
- },
- downloadFile() {
- uni.showLoading({
- title: '正在保存'
- });
- uni.downloadFile({
- url: this.QrSrc,
- success: res => {
- if (res.statusCode === 200) {
- uni.saveImageToPhotosAlbum({
- filePath: res.tempFilePath,
- success: function() {
- uni.showToast({
- title: '保存成功',
- icon: 'none'
- });
- },
- fail: function() {
- uni.showToast({
- title: '保存失败,请稍后重试',
- icon: 'none'
- });
- }
- });
- }
- },
- fail: err => {
- uni.showToast({
- title: '保存失败,请稍后重试',
- icon: 'none'
- });
- }
- });
- }
- }
- };
- </script>
- <style scoped lang="scss">
- .save-btn {
- width: 680upx;
- position: fixed;
- bottom: 30upx;
- left: 50%;
- transform: translateX(-50%);
- line-height: 80upx;
- text-align: center;
- color: #ffffff;
- background: $uni-color-primary;
- height: 80upx;
- border-radius: 8upx;
- }
- .wx_code {
- width: 660upx;
- background-color: #fff;
- margin-top: 160upx;
- border-radius: 10upx;
- .wx_code_name {
- margin: 50upx 0 40upx 50upx;
- font-size: 32upx;
- .user-name {
- font-size: 28upx;
- color: #666666;
- padding-top: 6upx;
- }
- }
- .wx_code_scan {
- width: 540upx;
- height: 540upx;
- margin: 0 auto;
- }
- .wx_code_scan image {
- width: 540upx;
- height: 540upx;
- }
- .wx_code_tips {
- margin: 50upx 0;
- font-size: 24upx;
- color: #999999;
- text-align: center;
- }
- }
- </style>
|