Browse Source

1.优化保存小程序码
2.优化复制微信号
3.优化其他

Zhou Jianjia 3 years ago
parent
commit
a0209b78f1
7 changed files with 74 additions and 26 deletions
  1. 47 15
      core/util.js
  2. 3 2
      pages/index/index.vue
  3. 15 3
      pages/login/login.vue
  4. 4 1
      pages/my/index.vue
  5. 2 2
      pages/my/member.vue
  6. 3 3
      pages/share/index.vue
  7. BIN
      static/images/member-bg.png

+ 47 - 15
core/util.js

xqd xqd
@@ -154,21 +154,52 @@ const login = () => {
 }
 
 const saveImage = url => {
-    uni.downloadFile({
-        url: url,
-        success: (res) => {
-            if (res.statusCode === 200) {
-                console.log('下载成功');
-                uni.saveFile({
-                    tempFilePath: res.tempFilePath,
-                    success: function(red) {
-                        console.log('-->data',red)
-                        uni.$u.toast(`保存路径:${red.savedFilePath}`)
-                    }
-                });
-            }else{
-                uni.$u.toast(`保存失败`)
+    return new Promise((resolve, reject) => {
+        uni.downloadFile({
+            url: url,
+            success: (res) => {
+                if (res.statusCode === 200) {
+                    console.log('下载成功');
+                    uni.authorize({
+                        scope: 'scope.writePhotosAlbum',
+                        success() {
+                            uni.saveImageToPhotosAlbum({
+                                filePath: res.tempFilePath,
+                                success: function(red) {
+                                    uni.$u.toast(`保存成功`)
+                                    //uni.$u.toast(`保存路径:${red.savedFilePath}`)
+                                    resolve()
+                                },
+                                fail: function() {
+                                    uni.$u.toast(`保存失败`)
+                                    reject()
+                                }
+                            });
+                        },
+                        fail: err => {
+                            uni.$u.toast(`授权失败`+JSON.stringify(err))
+                            reject()
+                        }
+                    })
+                }else{
+                    uni.$u.toast(`保存失败`)
+                    reject()
+                }
+            },
+            fail: err => {
+                uni.$u.toast(`保存失败`+JSON.stringify(err))
+                reject()
             }
+        });
+    })
+}
+
+const copyText = text => {
+    uni.setClipboardData({
+        data: text,
+        success: function () {
+            uni.hideLoading();
+            uni.$u.toast(`复制成功`)
         }
     });
 }
@@ -193,5 +224,6 @@ export {
     shareMessage,
     share,
     login,
-    saveImage
+    saveImage,
+    copyText
 }

+ 3 - 2
pages/index/index.vue

xqd xqd
@@ -50,7 +50,8 @@
 			handleOpen(index){
 				if(this.setting.review_mode) return
 				if(this.vuex_user_data.is_vip == 0){
-					if(this.$platform === 'ios'){
+					this.modal.show = true
+					/*if(this.$platform === 'ios'){
 						uni.showModal({
 							title: '提示',
 							content: '由于相关规范,iOS功能暂不可用',
@@ -60,7 +61,7 @@
 						});
 					}else{
 						this.modal.show = true
-					}
+					}*/
 				}else{
 					this.$jump({url: mathLists[index].url,type:'to'})
 				}

+ 15 - 3
pages/login/login.vue

xqd xqd
@@ -1,8 +1,14 @@
 <template>
     <view class="login">
-        <view class="bg">
-            <u-image src="@/static/images/login-bg.jpg" width="100%" height="100%" mode="scaleToFill"></u-image>
-        </view>
+        <app-math-card v-for="(item,index) in mathLists"
+                       :key="index"
+                       :cover-image="item.coverImage"
+                       :title="item.title"
+                       :index="index"
+                       :custom-style="{marginLeft:index % 2 === 1 ? '20rpx' : 0}"
+                       @open="handleOpen"
+        >
+        </app-math-card>
         <u-popup v-model="modal.show" mode="bottom" :mask-close-able="false" border-radius="15">
             <view class="popup-content">
                 <view class="title">需要获取您的用户信息</view>
@@ -15,9 +21,15 @@
 </template>
 
 <script>
+    import appMathCard from "@/components/index/app-math-card"
+    import mathLists from "@/core/math-lists.js"
     export default {
+        components:{
+            appMathCard
+        },
         data() {
             return {
+                mathLists: mathLists,
                 redirect: '',
                 code: '',
                 modal: {

+ 4 - 1
pages/my/index.vue

xqd xqd
@@ -41,7 +41,7 @@
 				<u-cell-item title="分销中心" v-if="setting.open_share" :border-bottom="false" bg-color="#f9f9f9" @click="$jump({url:'/pages/share/index',type:'to'})">
 					<view slot="icon" class="icon share"></view>
 				</u-cell-item>
-				<u-cell-item title="微信号" :border-bottom="false" bg-color="#f9f9f9">
+				<u-cell-item title="微信号" :border-bottom="false" bg-color="#f9f9f9" @click="handleCopy">
 					{{setting.service_wechat}}
 					<view slot="icon" class="icon wechat"></view>
 				</u-cell-item>
@@ -155,6 +155,9 @@
 				this.$u.vuex(this.$const.USER_TOKEN,null)
 				this.$u.vuex(this.$const.USER_DATA,null)
 				this.$jump({url:'/pages/login/login?redirect=pages/my/index',type:'redirect'})
+			},
+			handleCopy(){
+				this.$util.copyText(this.setting.service_wechat)
 			}
 		},
 		onLoad(){

+ 2 - 2
pages/my/member.vue

xqd xqd
@@ -56,7 +56,7 @@
 			},
 			handleBuy(){
 				let _this = this;
-				if(this.$platform === 'ios'){
+				/*if(this.$platform === 'ios'){
 					uni.showModal({
 						title: '提示',
 						content: '由于相关规范,iOS功能暂不可用',
@@ -65,7 +65,7 @@
 						}
 					});
 					return false
-				}
+				}*/
 				uni.showLoading({title: '数据处理中...'})
 				this.$u.api.userBuy().then(data => {
 					uni.hideLoading();

+ 3 - 3
pages/share/index.vue

xqd
@@ -122,9 +122,9 @@
 				})
 			},
 			handleSave(){
-				this.$util.saveImage(this.userData.share_qrcode)
-				this.qrCodeModal.show = false
-
+				this.$util.saveImage(this.userData.share_qrcode).then(res => {
+					this.qrCodeModal.show = false
+				})
 			}
 		},
 		onLoad(){

BIN
static/images/member-bg.png