import $toast from "../utils/tool/toast"; export default { data:function () { return { authorize:false, // 用户是否授权 } }, methods:{ openSetting(){ this.buttonAuthorize = true; }, openPoster(){ this.$refs.poster && this.$refs.poster.open(); } }, onShow(){ if (this.buttonAuthorize) { this.buttonAuthorize = false; // 获取授权 uni.authorize({ scope:'scope.writePhotosAlbum', success: (res) =>{ this.authorize= true; }, fail:() => { this.authorize= false; } }); } }, created(){ this.buttonAuthorize = true; } }