调试支付

feature/v-xuexi
wangdong 8 months ago
parent 3c3103a783
commit c541051a8f
  1. 4
      components/PayDialog/index.vue
  2. 14
      manifest.json
  3. 20
      pages/index/index.vue
  4. 54
      pages/my/user_info.vue
  5. 4
      pages/special/order_store_list.vue
  6. 5
      store/index.js
  7. 220
      store/modules/app.js
  8. 3
      store/types/action-types.js
  9. 6
      store/types/muations-types.js

@ -261,9 +261,10 @@ export default {
if (this.pay_type_num === 40) {
backUrlCRshlcICwGdGY.useGold = this.useGold;
}
console.log(backUrlCRshlcICwGdGY);
try {
const data = await createOrder(backUrlCRshlcICwGdGY);
console.log(data.msg);
uni.hideLoading();
if (data.code === 200) {
this.$emit("change", {
@ -275,6 +276,7 @@ export default {
this.$emit("update:open", false);
}
} catch (err) {
console.log(err)
uni.hideLoading();
this.$util.showMsg(err.msg);
}

@ -1,9 +1,9 @@
{
"name" : "梦航学习宝",
"appid" : "__UNI__640EC10",
"description" : "1.1.4",
"versionName" : "1.0.14",
"versionCode" : 114,
"description" : "1.1.5",
"versionName" : "1.0.15",
"versionCode" : 115,
"transformPx" : false,
/* 5+App */
"app-plus" : {
@ -61,10 +61,10 @@
"dSYMs" : false,
"urltypes" : "zsff.xinbadaweb.cn",
"privacyDescription" : {
"NSPhotoLibraryUsageDescription" : "该应用需要读取你的相册,用于设置个人头像",
"NSPhotoLibraryAddUsageDescription" : "该应用需要写入你的相册,用于设置个人头像",
"NSLocationWhenInUseUsageDescription" : "该应用需要获取你的地理位置,以便为你推荐附近的线下课程",
"NSCameraUsageDescription" : "该应用需要调用摄像头,用于设置个人头像"
"NSPhotoLibraryUsageDescription" : "梦航学习宝需要读取你的相册,用于设置个人头像",
"NSPhotoLibraryAddUsageDescription" : "梦航学习宝需要写入你的相册,用于设置个人头像",
"NSLocationWhenInUseUsageDescription" : "梦航学习宝需要获取你的地理位置,以便为你推荐附近的线下课程",
"NSCameraUsageDescription" : "梦航学习宝需要调用摄像头,用于设置个人头像"
},
"idfa" : false
},

@ -566,6 +566,7 @@ import ColorThief from "colorthief";
import SquareStyleCourse from '@/components/Course/squareStyleCourse.vue';
import Advert from '@/components/Advert/index.vue';
import { SET_POSITION } from "@/store/types/muations-types";
import { REQUEST_PERMISSIONS } from "@/store/types/action-types";
import { getLocation } from './getLocation.js';
import { changeCategory } from '@/api/learning';
@ -626,7 +627,7 @@ export default {
},
onLoad() {
wx.setNavigationBarTitle({
title:"一合知道"
title:"梦航学习宝"
});
let platform = uni.getSystemInfoSync().platform;
if (platform !== 'android') {
@ -921,15 +922,28 @@ export default {
}
);
},
toPosition() {
async toPosition() {
// #ifdef APP-PLUS
let result = await store.dispatch("app/" + REQUEST_PERMISSIONS, 'ACCESS_FINE_LOCATION')
if (result !== 1) return
if (this.currentPosition) {
uni.navigateTo({
url: `/pages/index/position?position=${this.currentPosition}`,
});
} else {
this.authPosition();
}
// #endif
// #ifndef APP-PLUS
let platform = uni.getSystemInfoSync().platform;
if (platform === 'android' && !this.currentPosition) {
if (platform === 'android' || !this.currentPosition) {
this.authPosition();
} else {
uni.navigateTo({
url: `/pages/index/position?position=${this.currentPosition}`,
});
}
// #endif
},
},
};

@ -79,10 +79,12 @@
<script>
import userInfoMixin from "@/mixins/userInfo";
import store from "@/store";
import { changePwd, getAuthCode, saveUserInfo, logout, deleteUser } from "@/api/user";
import { VALID_LOGIN_STATUS } from "@/store/types/action-types";
import { VALID_LOGIN_STATUS, REQUEST_PERMISSIONS } from "@/store/types/action-types";
import { SET_LOGIN, SET_LOGOUT } from "@/store/types/muations-types";
export default {
mixins: [userInfoMixin],
data() {
@ -122,25 +124,37 @@ export default {
console.log(e.detail.code)
},
async handlePickAvatar() {
const { tempFilePaths } = await this.$util.wrapFn(uni.chooseImage, {
count: 1,
extension: ["png", "jpg", "jpeg"],
});
const path = tempFilePaths[0];
uni.showLoading({
mask: true,
});
try {
console.log(path);
const result = await this.$util.uploadImg(path);
this.xUserInfo.avatar = result;
uni.hideLoading();
} catch (err) {
uni.hideLoading();
this.$util.showMsg(err.msg || err);
}
},
// #ifdef APP-PLUS
let result = await store.dispatch("app/" + REQUEST_PERMISSIONS, 'CAMERA')
if (result !== 1) return
let result1 = await store.dispatch("app/" + REQUEST_PERMISSIONS, 'WRITE_EXTERNAL_STORAGE')
if (result1 !== 1) return
this.chooseImage();
// #endif
// #ifdef APP-PLUS
this.chooseImage();
// #endif
},
async chooseImage() {
const { tempFilePaths } = await this.$util.wrapFn(uni.chooseImage, {
count: 1,
extension: ["png", "jpg", "jpeg"],
});
const path = tempFilePaths[0];
uni.showLoading({
mask: true,
});
try {
console.log(path);
const result = await this.$util.uploadImg(path);
this.xUserInfo.avatar = result;
uni.hideLoading();
} catch (err) {
uni.hideLoading();
this.$util.showMsg(err.msg || err);
}
},
async save_user_info() {
let { nickname, avatar, email } = this.xUserInfo;
nickname = nickname.trim();

@ -241,6 +241,7 @@
this.id = order.id;
this.money = order.pay_price;
this.payDialogOpen = true;
console.log(order);
},
userTake(item) {
uni.showModal({
@ -264,6 +265,7 @@
},
pay_order(data) {
this.orderId = data.data.result.orderId || "";
console.log(data, 267);
switch (data.data.status) {
case "PAY_ERROR":
case "ORDER_EXIST":
@ -307,6 +309,7 @@
},
extendOrder: function (msg) {
console.log(msg, 310);
this.payDialogOpen = false;
if (typeof msg === "object") {
if (msg.errMsg === "chooseWXPay:cancel") {
@ -322,6 +325,7 @@
},
//
changeVal: function (opt) {
console.log(opt, 327)
if (typeof opt != "object") opt = {};
var action = opt.action || "";
var value = opt.value || "";

@ -16,5 +16,10 @@ export default new Vuex.Store({
rootFontSize: state => state.app.rootFontSize,
token: state => state.app.token,
position: state => state.app.position,
CAMERA: state => state.app.CAMERA,
WRITE_EXTERNAL_STORAGE: state => state.app.WRITE_EXTERNAL_STORAGE,
ACCESS_FINE_LOCATION: state => state.app.ACCESS_FINE_LOCATION,
mapping: state => state.app.mapping,
}
})

@ -1,5 +1,5 @@
import { SET_LOGIN, SET_LOGOUT, SET_ROOT_FONT, UPDATE_USER_INFO, SET_POSITION } from "@/store/types/muations-types";
import { VALID_LOGIN_STATUS } from "@/store/types/action-types";
import { SET_LOGIN, SET_LOGOUT, SET_ROOT_FONT, UPDATE_USER_INFO, SET_POSITION, SET_CAMERA, SET_WRITE_EXTERNAL_STORAGE, SET_ACCESS_FINE_LOCATION } from "@/store/types/muations-types";
import { VALID_LOGIN_STATUS, REQUEST_PERMISSIONS } from "@/store/types/action-types";
import { validLoginStatus } from "@/api/user";
import utils from "@/utils/utils";
import baseConfig from "@/config";
@ -35,11 +35,35 @@ export default {
namespaced: true,
state() {
return {
isLogin: !!getToken(),
token: getToken(),
userInfo: getBaseUserInfo(),
rootFontSize: "50px",
position: '',
isLogin: !!getToken(),
token: getToken(),
userInfo: getBaseUserInfo(),
rootFontSize: "50px",
position: '',
// 处理应用程序权限请求
CAMERA:false,
WRITE_EXTERNAL_STORAGE: false,
ACCESS_FINE_LOCATION: false,
/* #ifdef APP-PLUS */
isIos: plus.os.name == "iOS",
/* #endif */
mapping: {
'CAMERA': {
title: "摄像头权限说明",
content: "梦航学习宝需要调用摄像头,用于设置个人头像",
methods: 'SET_CAMERA'
},
'WRITE_EXTERNAL_STORAGE': {
title: "梦航学习宝对存储空间/照片权限申请说明",
content: "梦航学习宝需要读取你的相册,用于设置个人头像",
methods: 'SET_WRITE_EXTERNAL_STORAGE'
},
'ACCESS_FINE_LOCATION': {
title: "梦航学习宝对地理位置权限申请说明",
content: "梦航学习需要获取你的地理位置,以便为你推荐附近的线下课程",
methods: 'SET_ACCESS_FINE_LOCATION'
},
}
}
},
mutations: {
@ -78,6 +102,16 @@ export default {
state.position = res;
utils.setStorage('position', res);
},
// 管理权限告知目的
[SET_CAMERA](state, val) {
state.CAMERA = val
},
[SET_WRITE_EXTERNAL_STORAGE](state, val) {
state.WRITE_EXTERNAL_STORAGE = val
},
[SET_ACCESS_FINE_LOCATION](state, val) {
state.ACCESS_FINE_LOCATION = val
}
},
actions: {
async [VALID_LOGIN_STATUS]({ commit }) {
@ -88,6 +122,176 @@ export default {
commit(SET_LOGOUT);
// console.log(err);
}
}
},
//权限获取
async [REQUEST_PERMISSIONS]({state,dispatch,commit}, permissionID) {
try {
if (!state[permissionID] && !state.isIos) {
var viewObj = await dispatch('nativeObjView', permissionID);
viewObj.show();
}
console.log('android.permission.' + permissionID, '当前手机权限');
return new Promise(async (resolve, reject) => {
//苹果不需要这个
if (state.isIos) {
resolve(1);
return
}
// Android权限查询
function requestAndroidPermission(permissionID_) {
return new Promise((resolve, reject) => {
plus.android.requestPermissions(
[permissionID_], // 理论上支持多个权限同时查询,但实际上本函数封装只处理了一个权限的情况。有需要的可自行扩展封装
function(resultObj) {
console.log(resultObj, 'resultObj')
var result = 0;
for (var i = 0; i < resultObj.granted.length; i++) {
// var grantedPermission = resultObj.granted[i];
// console.log('已获取的权限:' + grantedPermission);
result = 1
}
for (var i = 0; i < resultObj.deniedPresent.length; i++) {
// var deniedPresentPermission = resultObj.deniedPresent[i];
// console.log('拒绝本次申请的权限:' + deniedPresentPermission);
result = 0
}
for (var i = 0; i < resultObj.deniedAlways.length; i++) {
// var deniedAlwaysPermission = resultObj.deniedAlways[i];
// console.log('永久拒绝申请的权限:' + deniedAlwaysPermission);
result = -1
}
resolve(result);
},
function(error) {
console.log('申请权限错误:' + error.code + " = " + error
.message);
resolve({
code: error.code,
message: error.message
});
}
);
});
}
const result = await requestAndroidPermission(
'android.permission.' + permissionID
);
if (result === 1) {
//'已获得授权'
commit(state.mapping[permissionID].methods, true)
} else if (result === 0) {
//'未获得授权'
commit(state.mapping[permissionID].methods, false)
} else {
commit(state.mapping[permissionID].methods, true)
uni.showModal({
title: '提示',
content: '操作权限已被拒绝,请手动前往设置',
confirmText: "立即设置",
success: (res) => {
if (res.confirm) {
dispatch('gotoAppPermissionSetting')
}
}
})
}
if (viewObj) viewObj.close()
resolve(result);
});
} catch (error) {
console.log(error);
reject(error);
}
},
//提示框
nativeObjView({state}, permissionID) {
const systemInfo = uni.getSystemInfoSync();
const statusBarHeight = systemInfo.statusBarHeight;
const navigationBarHeight = systemInfo.platform === 'android' ? 48 :
44; // Set the navigation bar height based on the platform
const totalHeight = statusBarHeight + navigationBarHeight;
let view = new plus.nativeObj.View('per-modal', {
top: '0px',
left: '0px',
width: '100%',
backgroundColor: '#444',
//opacity: .5;
})
view.drawRect({
color: '#fff',
radius: '5px'
}, {
top: totalHeight + 'px',
left: '5%',
width: '90%',
height: "100px",
})
view.drawText(state.mapping[permissionID].title, {
top: totalHeight + 5 + 'px',
left: "8%",
height: "30px"
}, {
align: "left",
color: "#000",
}, {
onClick: function(e) {
console.log(e);
}
})
view.drawText(state.mapping[permissionID].content, {
top: totalHeight + 35 + 'px',
height: "60px",
left: "8%",
width: "84%"
}, {
whiteSpace: 'normal',
size: "14px",
align: "left",
color: "#656563"
})
function show() {
view = plus.nativeObj.View.getViewById('per-modal');
view.show()
view = null //展示的时候也得清空,不然影响下次的关闭,不知道为啥
}
function close() {
view = plus.nativeObj.View.getViewById('per-modal');
view.close();
view = null
}
return {
show,
close
}
},
// 跳转到**应用**的权限页面
gotoAppPermissionSetting({state}) {
if (state.isIos) {
var UIApplication = plus.ios.import("UIApplication");
var application2 = UIApplication.sharedApplication();
var NSURL2 = plus.ios.import("NSURL");
// var setting2 = NSURL2.URLWithString("prefs:root=LOCATION_SERVICES");
var setting2 = NSURL2.URLWithString("app-settings:");
application2.openURL(setting2);
plus.ios.deleteObject(setting2);
plus.ios.deleteObject(NSURL2);
plus.ios.deleteObject(application2);
} else {
// console.log(plus.device.vendor);
var Intent = plus.android.importClass("android.content.Intent");
var Settings = plus.android.importClass("android.provider.Settings");
var Uri = plus.android.importClass("android.net.Uri");
var mainActivity = plus.android.runtimeMainActivity();
var intent = new Intent();
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
var uri = Uri.fromParts("package", mainActivity.getPackageName(), null);
intent.setData(uri);
mainActivity.startActivity(intent);
}
}
}
}

@ -1 +1,2 @@
export const VALID_LOGIN_STATUS = "VALID_LOGIN_STATUS";
export const VALID_LOGIN_STATUS = "VALID_LOGIN_STATUS";
export const REQUEST_PERMISSIONS = 'REQUEST_PERMISSIONS';

@ -2,4 +2,8 @@ export const SET_LOGIN = "SET_LOGIN";
export const SET_LOGOUT = "SET_LOGOUT";
export const SET_ROOT_FONT = "SET_ROOT_FONT";
export const UPDATE_USER_INFO = "UPDATE_USER_INFO";
export const SET_POSITION = "SET_POSITION";
export const SET_POSITION = "SET_POSITION";
export const SET_CAMERA = "SET_CAMERA";
export const SET_WRITE_EXTERNAL_STORAGE = "SET_WRITE_EXTERNAL_STORAGE";
export const SET_ACCESS_FINE_LOCATION = "SET_ACCESS_FINE_LOCATION";
Loading…
Cancel
Save