瀏覽代碼

小程序退出功能

PC-20180523CIYM\Administrator 5 年之前
父節點
當前提交
2d349bdcf4
共有 4 個文件被更改,包括 24 次插入1 次删除
  1. 11 0
      pages/login/login.js
  2. 1 0
      pages/login/login.wxml
  3. 11 0
      pages/login/login.wxss
  4. 1 1
      project.config.json

+ 11 - 0
pages/login/login.js

@@ -7,6 +7,7 @@ Page({
    * 页面的初始数据
    */
   data: {
+    exitApp: false,
     canIUse: wx.canIUse('button.open-type.getUserInfo')
   },
 
@@ -14,6 +15,7 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
+    let self = this
     prevpage = options.prevpage ? options.prevpage : '/pages/index/index'
     if (options.prevpage && options.querys) {
       let querys = ''
@@ -23,6 +25,15 @@ Page({
       querys = '?' + querys.slice(0, querys.length - 1)
       prevpage = prevpage + querys
     }
+    wx.getSystemInfo({
+      success: function(res) {
+        if (res.SDKVersion >= '2.1.0') {
+          self.setData({
+            exitApp: true
+          })
+        }
+      },
+    })
   },
   getUserInfoEvent: function (e) {
     let that = this

+ 1 - 0
pages/login/login.wxml

@@ -9,5 +9,6 @@
   <button type="primary" open-type="getUserInfo" bindgetuserinfo="getUserInfoEvent" class="btn_login" wx:if="{{ canIUse }}">
   授权登陆
   </button>
+  <navigator wx:if="{{exitApp}}" open-type="exit" target="miniProgram" class="exitapp">退出</navigator>
 <view class="login_upgrade" wx:else>您的微信版本过低,请升级微信版本后登陆</view>
 </view>

+ 11 - 0
pages/login/login.wxss

@@ -53,4 +53,15 @@
   text-align: center;
   font-size: 34rpx;
   color: red;
+}
+.exitapp {
+  width: 85%;
+  margin: 10px auto 0;
+  display: block;
+  font-size: 18px;
+  line-height: 2.5;
+  text-align: center;
+  border-radius: 5px;
+  border: 1px #ddd solid;
+  background: #fefefe;
 }

+ 1 - 1
project.config.json

@@ -14,7 +14,7 @@
 		"checkInvalidKey": true
 	},
 	"compileType": "miniprogram",
-	"libVersion": "2.6.6",
+	"libVersion": "2.8.3",
 	"appid": "wxb2c3f3d048bfb8e5",
 	"projectname": "dw_lotter_draw",
 	"debugOptions": {