feat: 添加公共方法

This commit is contained in:
mayubo@gmail.com 2025-04-15 18:01:57 +08:00
parent ae0d45cedd
commit 5c30c7165f
19 changed files with 268 additions and 158 deletions

View File

@ -80,6 +80,7 @@
this.init(); this.init();
}, },
methods: { methods: {
async init() { async init() {
console.log('123'); console.log('123');
const res = await request(apiArr.shopList, 'POST', { const res = await request(apiArr.shopList, 'POST', {

View File

@ -1,43 +1,154 @@
<template> <template>
<view> <view class="box" :style="{paddingTop: top + 'px'}">
<u-navbar <u-navbar
title="充值缴费" title="充值缴费"
@rightClick="rightClick" @leftClick="leftClick"
leftIconSize="" bgColor="transparent"
leftIconSize="20px"
:autoBack="true" :autoBack="true"
/> />
<view class="box" style="margin-top: 100px"> <view class="msg">
<view class="msg"> 账户余额()
账户余额() <view>{{money}}</view>
<view>{{money}}</view> <image src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/kitchen/recharge_img.png" mode="widthFix" />
<image src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/kitchen/recharge_img.png" mode="widthFix" />
</view>
<view class="recharge">
<view class="rechargeTit">充值金额</view>
<view class="iptbox">
<view></view>
<input type="number" :value="amount" bind:input="headerAmountClick" placeholder="请输入充值金额" placeholder-style="color: #999999;font-size: 24rpx;" />
</view>
<view class="btn" @Click="headerSubmitClick">
确认充值
</view>
</view>
</view> </view>
<view class="recharge">
<view class="rechargeTit">充值金额</view>
<view class="iptbox">
<view></view>
<input type="number" :value="amount" @input="headerAmountClick" placeholder="请输入充值金额" placeholder-style="color: #999999;font-size: 24rpx;" />
</view>
<view class="btn" @click="headerSubmitClick">
确认充值
</view>
</view>
</view> </view>
</template> </template>
<script> <script>
import { menuButtonInfo, request } from '../../utils/index';
import { apiArr } from '../../api/kitchen';
export default { export default {
data() { data() {
return { return {
money: 0, // top: 85,
amount: '', money: 0, //
GoodsMsg: {}, amount: '',
goodsMsg: {},
}; };
}, },
onLoad() {
const meun = menuButtonInfo();
this.top = meun.height + meun.top;
this.init();
},
methods: {
//
leftClick() {
uni.navigateBack({
delta: 1
})
},
async init(){
// const res = await request(apiArr.balance, 'POST',{});
// console.log('erer', res);
const res = {
money: 4
};
this.money = res.money
},
headerAmountClick(e) {
this.amount = e.detail.value
},
async headerSubmitClick() {
console.log('12313', this);
return;
const res = request(apiArr.recharge, 'POST', {money: Number(this.amount)}, {silent: false});
this.goodsMsg = res;
this.pay(res);
},
// async pay(res) {
// const res = request(apiArr.recharge, 'POST', {money: Number(this.amount)});
// }
pay(res){
let that = this
util.postUrl2(PayJs.pay,{
address: '',
goods_id: String(res.order.id),
merchant_no: res.merchant_no,
out_trade_no: res.order.order_no,
quantity: 1,
remark: '',
subject: '用户充值',
term_no: res.term_no,
total_amount: String(res.order.money * 100),
// total_amount:String(1),
user: String(wx.getStorageSync('userId')),
user_id: wx.getStorageSync('openId')
},res=>{
const {resp_data,msg} = res.data;
console.log('1123313', res);
wx.hideLoading()
if(msg == '成功'){
wx.requestPayment({
timeStamp:String(resp_data.acc_resp_fields.time_stamp),
nonceStr:String(resp_data.acc_resp_fields.nonce_str),
package:String(resp_data.acc_resp_fields.package),
signType:String(resp_data.acc_resp_fields.sign_type),
paySign:String(resp_data.acc_resp_fields.pay_sign),
success(res){
console.log('1111', res);
that.setData({
amount: ''
});
that.queryPay()
},
fail(fal){
console.log(fal);
}
})
}
})
},
queryPay(){
let that = this
const { GoodsMsg } = that.data;
console.log('queryPayqueryPayqueryPayqueryPayqueryPay', GoodsMsg);
util.postUrl2(PayJs.queryPay,{
merchant_no: GoodsMsg.merchant_no,
term_no: GoodsMsg.term_no,
out_trade_no: GoodsMsg.order.order_no
},res=>{
console.log('resresresresresresresresres', res);
if(res.statusCode == '200'){
wx.showToast({
title: '支付成功!',
success() {
setTimeout(() => {
that.getBanlance()
}, 1500)
}
})
}else{
wx.showToast({
title: res.msg,
})
}
})
},
},
} }
</script> </script>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -19298,7 +19298,7 @@ var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/inte
Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "__esModule", {
value: true value: true
}); });
exports.upload = exports.request = exports.picUrl = exports.isPhone = exports.floatCalculate = exports.NavgateTo = void 0; exports.upload = exports.request = exports.picUrl = exports.menuButtonInfo = exports.isPhone = exports.floatCalculate = exports.NavgateTo = void 0;
var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ 11)); var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ 11));
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@ -19532,6 +19532,10 @@ var upload = function upload(filename, fn) {
}); });
}; };
exports.upload = upload; exports.upload = upload;
var menuButtonInfo = function menuButtonInfo() {
return uni.getMenuButtonBoundingClientRect();
};
exports.menuButtonInfo = menuButtonInfo;
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/@dcloudio/uni-mp-weixin/dist/index.js */ 2)["default"])) /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/@dcloudio/uni-mp-weixin/dist/index.js */ 2)["default"]))
/***/ }), /***/ }),
@ -19734,7 +19738,108 @@ exports.default = _default;
/* 220 */, /* 220 */,
/* 221 */, /* 221 */,
/* 222 */, /* 222 */,
/* 223 */, /* 223 */
/*!************************************************************************************!*\
!*** F:/program/qjl/uniapp-ZHSQ/uni_modules/uview-ui/components/u-navbar/props.js ***!
\************************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(uni) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _default = {
props: {
// 是否开启顶部安全区适配
safeAreaInsetTop: {
type: Boolean,
default: uni.$u.props.navbar.safeAreaInsetTop
},
// 固定在顶部时,是否生成一个等高元素,以防止塌陷
placeholder: {
type: Boolean,
default: uni.$u.props.navbar.placeholder
},
// 是否固定在顶部
fixed: {
type: Boolean,
default: uni.$u.props.navbar.fixed
},
// 是否显示下边框
border: {
type: Boolean,
default: uni.$u.props.navbar.border
},
// 左边的图标
leftIcon: {
type: String,
default: uni.$u.props.navbar.leftIcon
},
// 左边的提示文字
leftText: {
type: String,
default: uni.$u.props.navbar.leftText
},
// 左右的提示文字
rightText: {
type: String,
default: uni.$u.props.navbar.rightText
},
// 右边的图标
rightIcon: {
type: String,
default: uni.$u.props.navbar.rightIcon
},
// 标题
title: {
type: [String, Number],
default: uni.$u.props.navbar.title
},
// 背景颜色
bgColor: {
type: String,
default: uni.$u.props.navbar.bgColor
},
// 标题的宽度
titleWidth: {
type: [String, Number],
default: uni.$u.props.navbar.titleWidth
},
// 导航栏高度
height: {
type: [String, Number],
default: uni.$u.props.navbar.height
},
// 左侧返回图标的大小
leftIconSize: {
type: [String, Number],
default: uni.$u.props.navbar.leftIconSize
},
// 左侧返回图标的颜色
leftIconColor: {
type: String,
default: uni.$u.props.navbar.leftIconColor
},
// 点击左侧区域(返回图标),是否自动返回上一页
autoBack: {
type: Boolean,
default: uni.$u.props.navbar.autoBack
},
// 标题的样式,对象或字符串
titleStyle: {
type: [String, Object],
default: uni.$u.props.navbar.titleStyle
}
}
};
exports.default = _default;
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/@dcloudio/uni-mp-weixin/dist/index.js */ 2)["default"]))
/***/ }),
/* 224 */, /* 224 */,
/* 225 */, /* 225 */,
/* 226 */, /* 226 */,
@ -20937,124 +21042,6 @@ var _default = {
exports.default = _default; exports.default = _default;
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/@dcloudio/uni-mp-weixin/dist/index.js */ 2)["default"])) /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/@dcloudio/uni-mp-weixin/dist/index.js */ 2)["default"]))
/***/ }),
/* 300 */,
/* 301 */,
/* 302 */,
/* 303 */,
/* 304 */,
/* 305 */,
/* 306 */,
/* 307 */,
/* 308 */,
/* 309 */,
/* 310 */,
/* 311 */,
/* 312 */,
/* 313 */,
/* 314 */,
/* 315 */,
/* 316 */
/*!************************************************************************************!*\
!*** F:/program/qjl/uniapp-ZHSQ/uni_modules/uview-ui/components/u-navbar/props.js ***!
\************************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(uni) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _default = {
props: {
// 是否开启顶部安全区适配
safeAreaInsetTop: {
type: Boolean,
default: uni.$u.props.navbar.safeAreaInsetTop
},
// 固定在顶部时,是否生成一个等高元素,以防止塌陷
placeholder: {
type: Boolean,
default: uni.$u.props.navbar.placeholder
},
// 是否固定在顶部
fixed: {
type: Boolean,
default: uni.$u.props.navbar.fixed
},
// 是否显示下边框
border: {
type: Boolean,
default: uni.$u.props.navbar.border
},
// 左边的图标
leftIcon: {
type: String,
default: uni.$u.props.navbar.leftIcon
},
// 左边的提示文字
leftText: {
type: String,
default: uni.$u.props.navbar.leftText
},
// 左右的提示文字
rightText: {
type: String,
default: uni.$u.props.navbar.rightText
},
// 右边的图标
rightIcon: {
type: String,
default: uni.$u.props.navbar.rightIcon
},
// 标题
title: {
type: [String, Number],
default: uni.$u.props.navbar.title
},
// 背景颜色
bgColor: {
type: String,
default: uni.$u.props.navbar.bgColor
},
// 标题的宽度
titleWidth: {
type: [String, Number],
default: uni.$u.props.navbar.titleWidth
},
// 导航栏高度
height: {
type: [String, Number],
default: uni.$u.props.navbar.height
},
// 左侧返回图标的大小
leftIconSize: {
type: [String, Number],
default: uni.$u.props.navbar.leftIconSize
},
// 左侧返回图标的颜色
leftIconColor: {
type: String,
default: uni.$u.props.navbar.leftIconColor
},
// 点击左侧区域(返回图标),是否自动返回上一页
autoBack: {
type: Boolean,
default: uni.$u.props.navbar.autoBack
},
// 标题的样式,对象或字符串
titleStyle: {
type: [String, Object],
default: uni.$u.props.navbar.titleStyle
}
}
};
exports.default = _default;
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/@dcloudio/uni-mp-weixin/dist/index.js */ 2)["default"]))
/***/ }) /***/ })
]]); ]]);
//# sourceMappingURL=../../.sourcemap/mp-weixin/common/vendor.js.map //# sourceMappingURL=../../.sourcemap/mp-weixin/common/vendor.js.map

View File

@ -4,6 +4,13 @@
"condition": { "condition": {
"miniprogram": { "miniprogram": {
"list": [ "list": [
{
"name": "kitchen/recharge/index",
"pathName": "kitchen/recharge/index",
"query": "",
"launchMode": "default",
"scene": null
},
{ {
"name": "kitchen/pay/index", "name": "kitchen/pay/index",
"pathName": "kitchen/pay/index", "pathName": "kitchen/pay/index",

View File

@ -215,3 +215,7 @@ export const upload = (filename, fn) => {
complete: () => {} complete: () => {}
}); });
} }
export const menuButtonInfo = () => {
return uni.getMenuButtonBoundingClientRect()
}