Commit 187cc156 authored by jiangjiantao's avatar jiangjiantao

支付页面和支付结果页面

支付页面和支付结果页面
parent d435cd0a
......@@ -10,5 +10,7 @@ App({
userInfo: null,
version: "1.0.6.20200310",
BASE_URL: "https://hhms.miyapay.com/",
localAccountInfo:null,
useTestPayInfo:true
}
})
\ No newline at end of file
{
"pages": [
"pages/login/login",
"pages/pay_result/pay_result",
"pages/logs/logs",
"pages/functioncenter/functioncenter",
"pages/refund/refund",
"pages/login/login",
"pages/balance/balance",
"pages/operation_waiting/operation_waiting",
"pages/home/home",
"pages/index/index",
"pages/logs/logs"
"pages/index/index"
],
"window": {
"navigationStyle": "custom",
......
module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 17);
/******/ })
/************************************************************************/
/******/ ({
/***/ 17:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Component({
options: {
multipleSlots: true,
// 在组件定义时的选项中启用多slot支持
addGlobalClass: true
},
properties: {
closabled: {
// 是否具有关闭标签
type: Boolean,
value: true
},
title: {
// 标题,也可以通过 slot 自定义
type: String,
value: ''
},
subTitle: {
// 副标题,也可以通过 slot 自定义
type: String,
value: ''
},
extClass: {
// 弹窗 class
type: String,
value: ''
},
desc: {
type: String,
value: ''
},
tips: {
type: String,
value: ''
},
maskClosable: {
type: Boolean,
value: true
},
mask: {
// 是否需要 遮罩层
type: Boolean,
value: true
},
show: {
// 是否开启弹窗
type: Boolean,
value: false,
observer: '_showChange'
},
buttons: {
type: Array,
value: [] // {text, extClass}
}
},
lifetimes: {
attached() {
console.log('hellow ')
}
},
methods: {
close(e) {
const {
type
} = e.currentTarget.dataset;
if (this.data.maskClosable || type === 'close') {
this.setData({
show: false
}); // 关闭弹窗回调事件
this.triggerEvent('close');
}
},
buttonTap(e) {
const {
index
} = e.currentTarget.dataset;
this.triggerEvent('buttontap', {
index,
item: this.data.buttons[index]
}, {});
},
onMaskMouseMove(e) {// do nothing
}
}
});
/***/ })
/******/ });
\ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
<view class="{{show ? 'weui-show' :'weui-hidden'}}">
<view class="weui-mask init" wx:if="{{mask}}" bindtap="close" catch:touchmove="onMaskMouseMove" data-type="tap"></view>
<view class="weui-half-screen-dialog {{extClass}}">
<view class="weui-half-screen-dialog__hd">
<view wx:if="{{closabled}}" class="weui-half-screen-dialog__hd__side_self" bindtap="close" data-type="close">
<view class="weui-icon-btn weui-icon-btn_close" hover-class="weui-active">关闭</view>
</view>
<view wx:if="{{false}}" class="weui-half-screen-dialog__hd__main">
<block wx:if="{{title}}">
<text class="weui-half-screen-dialog__title">{{title}}</text>
<text class="weui-half-screen-dialog__subtitle">{{subTitle}}</text>
</block>
<block wx:else>
<view class="weui-half-screen-dialog__title"><slot name="title"></slot></view>
</block>
</view>
<view class="weui-half-screen-dialog__hd__side">
<view class="weui-icon-btn weui-icon-btn_more" hover-class="weui-active">更多</view>
</view>
</view>
<view class="weui-half-screen-dialog__bd">
<block wx:if="{{title}}">
<view class="weui-half-screen-dialog__desc_self">{{desc}}</view>
<view class="weui-half-screen-dialog__tips_self">{{tips}}</view>
</block>
<slot name="desc" wx:else></slot>
</view>
<view class="sacn-pay-guide">
</view>
<view class="weui-half-screen-dialog__ft">
<block wx:if="{{buttons && buttons.length}}">
<button
wx:for="{{buttons}}"
wx:key="index"
type="{{item.type}}"
class="weui-btn {{item.className}}"
data-index="{{index}}"
bindtap="buttonTap"
>{{item.text}}</button>
</block>
<slot name="footer" wx:else></slot>
</view>
</view>
</view>
\ No newline at end of file
// pages/balance/balance.js
var miyapay = require("../../utils/miyapay4.js");
Page({
/**
* 页面的初始数据
*/
data: {
payPriceYuan:"0.01"
payPriceYuan:"0.01",
show: false,
scanPayError:"",
saasid: "",
marketId: "",
posId: "",
cashierCode: "",
baseUrl: null,
signKey: "",
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.initData();
},
/**
* 生命周期函数--监听页面初次渲染完成
* 初始化数据
*/
onReady: function () {
initData(){
this.data.baseUrl = getApp().globalData.BASE_URL;
var localAccountInfo = getApp().globalData.localAccountInfo;
console.info("localAccountInfo==>" + JSON.stringify(localAccountInfo));
if (localAccountInfo.success == true && localAccountInfo.data != null) {
this.data.saasid = localAccountInfo.data.store.saasid;
if (localAccountInfo.data.store.marketid != null) {
this.data.marketId = localAccountInfo.data.store.marketid;
} else {
this.data.marketId = localAccountInfo.data.store.storeId;
}
this.data.posId = localAccountInfo.data.store.posId;
this.data.cashierCode = localAccountInfo.data.store.operatorId;
this.data.signKey = localAccountInfo.data.store.miyaPayPlatformSignKey;
this.data.baseUrl = localAccountInfo.data.store.miyaPayPlatformUrl + "";
this.data.apiVersion = localAccountInfo.data.store.miyaPayApiVersion;
if (getApp().globalData.useTestPayInfo == true) {
//just for test
this.data.signKey = "nbz9ww27sx4ou6dkr61mf63tth3s6e2d";
this.data.saasid = "miya";
this.data.marketId = "slzf";
this.data.posId = "1";
this.data.cashierCode = "1";
this.data.baseUrl = "https://paytest.miyapay.com/miya/miyapay_response.action";
}
}
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
* 刷脸支付
*/
onHide: function () {
facePay:function(){
this.doPay("23444764646446464644646446")
},
/**
* 生命周期函数--监听页面卸载
* 扫码支付
*/
onUnload: function () {
scanPay:function(){
this.setData({
show:true
})
},
/**
* 页面相关事件处理函数--监听用户下拉动作
* 请求支付
*/
onPullDownRefresh: function () {
doPay:function(payCode){
wx.showLoading({
title: '请稍后...',
})
//todo
var orderNo = (new Date()).getTime() + "";
miyapay.requestPay({
baseUrl: this.data.baseUrl,
type: miyapay.TYPE_BARCODE_PAY,
saasid: this.data.saasid,
marketId: this.data.marketId,
posId: this.data.posId,
cashierCode: this.data.cashierCode,
version: "1.5",
orderNo: orderNo,
token: payCode,
payPrice:miyapay.fen2Yuan(parseInt(this.data.payPriceYuan)),
signKey: this.data.signKey,
callback: (res) => {
console.log("支付回调==>" + JSON.stringify(res));
if (res.code == 0) {
//支付成功
this.paySuccess();
} else {
this.payFail(res.data);
}
wx.hideLoading({
success: (res) => {},
})
}
});
},
/**
* 页面上拉触底事件的处理函数
* 支付成功
*/
onReachBottom: function () {
paySuccess(){
wx.showToast({
title: "支付成功",
icon: 'success',
duration: 2000
})
wx.redirectTo({
url: '/pages/pay_result/pay_result?payPriceYuan='+this.data.payPriceYuan+"&description=支付成功",
})
},
/**
* 用户点击右上角分享
* 支付失败
*/
onShareAppMessage: function () {
payFail(msg) {
wx.redirectTo({
url: '/pages/pay_result/pay_result?payPriceYuan='+this.data.payPriceYuan+"&description=支付成功",
})
// if (this.data.show) {
// this.setData({
// scanPayError: msg
// })
// } else {
// wx.showToast({
// title: msg,
// icon: 'none',
// duration: 2000
// })
// }
}
})
\ No newline at end of file
{
"usingComponents": {}
"usingComponents": {
"scan-pay-dialog": "../../miniprogram_npm/weui-miniprogram/scan-pay-dialog/scan-pay-dialog"
}
}
\ No newline at end of file
<view class="page">
<view class="balance-top" >
<view class="balance-top">
<view class="wait-remind">请支付</view>
<view class="price">¥{{payPriceYuan}}</view>
......@@ -12,14 +12,24 @@
<view class="pay-way-item">
<image class="pay-way-image" src="../../images/face_pay.png"/>
<image class="pay-way-image" src="../../images/face_pay.png" bindtap="facePay"/>
<view>刷脸支付</view>
</view>
<view class="pay-way-item">
<image class="pay-way-image" src="../../images/qr_pay.png"/>
<image class="pay-way-image" src="../../images/qr_pay.png" bindtap="scanPay" />
<view>扫码支付</view>
</view>
</view>
</view>
<scan-pay-dialog
bindbuttontap="buttontap"
show="{{show}}"
maskClosable="{{false}}"
title="占位符"
subTitle="占位符"
desc="请扫描付款码支付"
tips="{{scanPayError}}"
></scan-pay-dialog>
\ No newline at end of file
......@@ -72,7 +72,7 @@ Page({
//todo 测试
var payPriceYuan = "0.01";
wx.navigateTo({
url: '/pages/operation_waiting/operation_waiting?payPriceYuan='+payPriceYuan,
url: '/pages/balance/balance?payPriceYuan='+payPriceYuan,
})
}
})
\ No newline at end of file
......@@ -113,7 +113,9 @@ Page({
duration: 2000
})
wx.setStorageSync('accountInfo', params)
wx.navigateTo({
//登录信息 =》 全局变量
getApp().globalData.localAccountInfo = res.data;
wx.redirectTo({
url: '/pages/home/home',
})
}else{
......
Page({
/**
* 页面的初始数据
*/
data: {
payPriceYuan:"0.00",
description:"支付成功",
goHomeCountDown:"3秒后跳转到首页",
payCountDownTimer:null,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var payPriceYuan = options.payPriceYuan
var description = options.description
this.setData({
payPriceYuan:payPriceYuan,
description:description
})
},
onShow:function(){
//回到首页倒计时
this.startPayCountDown();
},
/**
* 3秒倒计时结束 弹出选择支付方式
*/
startPayCountDown:function(){
this.setData({goHomeCountDown:"3秒后跳转到首页"})
if (this.data.payCountDownTimer != null) {
clearInterval(this.data.payCountDownTimer)
}
var countDown = 3;
var that = this;
var payCountDownTimer = setInterval(() => {
if(countDown <= 0){
that.backHome()
clearInterval(payCountDownTimer)
}else{
--countDown
that.setData({goHomeCountDown:countDown+"s秒后跳转到首页"})
}
}, 1000);
},
/**
* 回到首页
*/
backHome(){
wx.navigateBack({
delta: 1
})
}
})
\ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file
<view class="page">
<image class="icon-success" src="../../images/icon_success.png"/>
<view class="description">{{description}}</view>
<view class="price">¥{{payPriceYuan}}</view>
<view class="btn-go-home"><button type="default" bindtap="backHome" >回到首页</button>
</view>
<view class="count-down">{{goHomeCountDown}}</view>
</view>
\ No newline at end of file
.page{
display: flex;
flex-direction: column;
align-content: center;
align-items: center;
}
.icon-success{
width: 120rpx;
height: 120rpx;
margin-top: 266rpx;
}
.description{
font-size: 40rpx;
margin-top: 30rpx;
}
.price{
color: var(--main-color);
font-size: 80rpx;
margin-top:40rpx;
}
.btn-go-home{
width: 70%;
height: 115rpx;
margin-top: 120rpx;
}
.count-down{
font-size: 32rpx;
color: #788192;
margin-top: 290rpx;
}
\ No newline at end of file
!
function(n) {
"use strict";
function t(n, t) {
var r = (65535 & n) + (65535 & t),
e = (n >> 16) + (t >> 16) + (r >> 16);
return e << 16 | 65535 & r
}
function r(n, t) {
return n << t | n >>> 32 - t
}
function e(n, e, o, u, c, f) {
return t(r(t(t(e, n), t(u, f)), c), o)
}
function o(n, t, r, o, u, c, f) {
return e(t & r | ~t & o, n, t, u, c, f)
}
function u(n, t, r, o, u, c, f) {
return e(t & o | r & ~o, n, t, u, c, f)
}
function c(n, t, r, o, u, c, f) {
return e(t ^ r ^ o, n, t, u, c, f)
}
function f(n, t, r, o, u, c, f) {
return e(r ^ (t | ~o), n, t, u, c, f)
}
function i(n, r) {
n[r >> 5] |= 128 << r % 32,
n[(r + 64 >>> 9 << 4) + 14] = r;
var e, i, a, h, d, l = 1732584193,
g = -271733879,
v = -1732584194,
m = 271733878;
for (e = 0; e < n.length; e += 16) i = l,
a = g,
h = v,
d = m,
l = o(l, g, v, m, n[e], 7, -680876936),
m = o(m, l, g, v, n[e + 1], 12, -389564586),
v = o(v, m, l, g, n[e + 2], 17, 606105819),
g = o(g, v, m, l, n[e + 3], 22, -1044525330),
l = o(l, g, v, m, n[e + 4], 7, -176418897),
m = o(m, l, g, v, n[e + 5], 12, 1200080426),
v = o(v, m, l, g, n[e + 6], 17, -1473231341),
g = o(g, v, m, l, n[e + 7], 22, -45705983),
l = o(l, g, v, m, n[e + 8], 7, 1770035416),
m = o(m, l, g, v, n[e + 9], 12, -1958414417),
v = o(v, m, l, g, n[e + 10], 17, -42063),
g = o(g, v, m, l, n[e + 11], 22, -1990404162),
l = o(l, g, v, m, n[e + 12], 7, 1804603682),
m = o(m, l, g, v, n[e + 13], 12, -40341101),
v = o(v, m, l, g, n[e + 14], 17, -1502002290),
g = o(g, v, m, l, n[e + 15], 22, 1236535329),
l = u(l, g, v, m, n[e + 1], 5, -165796510),
m = u(m, l, g, v, n[e + 6], 9, -1069501632),
v = u(v, m, l, g, n[e + 11], 14, 643717713),
g = u(g, v, m, l, n[e], 20, -373897302),
l = u(l, g, v, m, n[e + 5], 5, -701558691),
m = u(m, l, g, v, n[e + 10], 9, 38016083),
v = u(v, m, l, g, n[e + 15], 14, -660478335),
g = u(g, v, m, l, n[e + 4], 20, -405537848),
l = u(l, g, v, m, n[e + 9], 5, 568446438),
m = u(m, l, g, v, n[e + 14], 9, -1019803690),
v = u(v, m, l, g, n[e + 3], 14, -187363961),
g = u(g, v, m, l, n[e + 8], 20, 1163531501),
l = u(l, g, v, m, n[e + 13], 5, -1444681467),
m = u(m, l, g, v, n[e + 2], 9, -51403784),
v = u(v, m, l, g, n[e + 7], 14, 1735328473),
g = u(g, v, m, l, n[e + 12], 20, -1926607734),
l = c(l, g, v, m, n[e + 5], 4, -378558),
m = c(m, l, g, v, n[e + 8], 11, -2022574463),
v = c(v, m, l, g, n[e + 11], 16, 1839030562),
g = c(g, v, m, l, n[e + 14], 23, -35309556),
l = c(l, g, v, m, n[e + 1], 4, -1530992060),
m = c(m, l, g, v, n[e + 4], 11, 1272893353),
v = c(v, m, l, g, n[e + 7], 16, -155497632),
g = c(g, v, m, l, n[e + 10], 23, -1094730640),
l = c(l, g, v, m, n[e + 13], 4, 681279174),
m = c(m, l, g, v, n[e], 11, -358537222),
v = c(v, m, l, g, n[e + 3], 16, -722521979),
g = c(g, v, m, l, n[e + 6], 23, 76029189),
l = c(l, g, v, m, n[e + 9], 4, -640364487),
m = c(m, l, g, v, n[e + 12], 11, -421815835),
v = c(v, m, l, g, n[e + 15], 16, 530742520),
g = c(g, v, m, l, n[e + 2], 23, -995338651),
l = f(l, g, v, m, n[e], 6, -198630844),
m = f(m, l, g, v, n[e + 7], 10, 1126891415),
v = f(v, m, l, g, n[e + 14], 15, -1416354905),
g = f(g, v, m, l, n[e + 5], 21, -57434055),
l = f(l, g, v, m, n[e + 12], 6, 1700485571),
m = f(m, l, g, v, n[e + 3], 10, -1894986606),
v = f(v, m, l, g, n[e + 10], 15, -1051523),
g = f(g, v, m, l, n[e + 1], 21, -2054922799),
l = f(l, g, v, m, n[e + 8], 6, 1873313359),
m = f(m, l, g, v, n[e + 15], 10, -30611744),
v = f(v, m, l, g, n[e + 6], 15, -1560198380),
g = f(g, v, m, l, n[e + 13], 21, 1309151649),
l = f(l, g, v, m, n[e + 4], 6, -145523070),
m = f(m, l, g, v, n[e + 11], 10, -1120210379),
v = f(v, m, l, g, n[e + 2], 15, 718787259),
g = f(g, v, m, l, n[e + 9], 21, -343485551),
l = t(l, i),
g = t(g, a),
v = t(v, h),
m = t(m, d);
return [l, g, v, m]
}
function a(n) {
var t, r = "";
for (t = 0; t < 32 * n.length; t += 8) r += String.fromCharCode(n[t >> 5] >>> t % 32 & 255);
return r
}
function h(n) {
var t, r = [];
for (r[(n.length >> 2) - 1] = void 0, t = 0; t < r.length; t += 1) r[t] = 0;
for (t = 0; t < 8 * n.length; t += 8) r[t >> 5] |= (255 & n.charCodeAt(t / 8)) << t % 32;
return r
}
function d(n) {
return a(i(h(n), 8 * n.length))
}
function l(n, t) {
var r, e, o = h(n),
u = [],
c = [];
for (u[15] = c[15] = void 0, o.length > 16 && (o = i(o, 8 * n.length)), r = 0; 16 > r; r += 1) u[r] = 909522486 ^ o[r],
c[r] = 1549556828 ^ o[r];
return e = i(u.concat(h(t)), 512 + 8 * t.length),
a(i(c.concat(e), 640))
}
function g(n) {
var t, r, e = "0123456789abcdef",
o = "";
for (r = 0; r < n.length; r += 1) t = n.charCodeAt(r),
o += e.charAt(t >>> 4 & 15) + e.charAt(15 & t);
return o
}
function v(n) {
return unescape(encodeURIComponent(n))
}
function m(n) {
return d(v(n))
}
function p(n) {
return g(m(n))
}
function s(n, t) {
return l(v(n), v(t))
}
function C(n, t) {
return g(s(n, t))
}
function A(n, t, r) {
return t ? r ? s(t, n) : C(t, n) : r ? m(n) : p(n)
}
"function" == typeof define && define.amd ? define(function() {
return A
}) : "object" == typeof module && module.exports ? module.exports = A: n.md5 = A
} (this);
\ No newline at end of file
This diff is collapsed.
export const floatObj = (function() {
/*
* 判断obj是否为一个整数
*/
function isInteger(obj) {
return Math.floor(obj) === obj;
}
/*
* 将一个浮点数转成整数,返回整数和倍数。如 3.14 >> 314,倍数是 100
* @param floatNum {number} 小数
* @return {object}
* {times:100, num: 314}
*/
function toInteger(floatNum) {
var ret = { times: 1, num: 0 };
if (isInteger(floatNum)) {
ret.num = floatNum;
return ret;
}
var strfi = floatNum + "";
var dotPos = strfi.indexOf(".");
var len = strfi.substr(dotPos + 1).length;
var times = Math.pow(10, len);
var intNum = parseInt(floatNum * times + 0.5, 10);
ret.times = times;
ret.num = intNum;
return ret;
}
/*
* 核心方法,实现加减乘除运算,确保不丢失精度
* 思路:把小数放大为整数(乘),进行算术运算,再缩小为小数(除)
*
* @param a {number} 运算数1
* @param b {number} 运算数2
* @param op {string} 运算类型,有加减乘除(add/subtract/multiply/divide)
*
*/
function operation(a, b, op) {
var o1 = toInteger(a);
var o2 = toInteger(b);
var n1 = o1.num;
var n2 = o2.num;
var t1 = o1.times;
var t2 = o2.times;
var max = t1 > t2 ? t1 : t2;
var result = null;
switch (op) {
case "add":
if (t1 === t2) {
// 两个小数位数相同
result = n1 + n2;
} else if (t1 > t2) {
// o1 小数位 大于 o2
result = n1 + n2 * (t1 / t2);
} else {
// o1 小数位 小于 o2
result = n1 * (t2 / t1) + n2;
}
return result / max;
case "subtract":
if (t1 === t2) {
result = n1 - n2;
} else if (t1 > t2) {
result = n1 - n2 * (t1 / t2);
} else {
result = n1 * (t2 / t1) - n2;
}
return result / max;
case "multiply":
result = (n1 * n2) / (t1 * t2);
return result;
case "divide":
result = (n1 / n2) * (t2 / t1);
return result;
}
}
// 加减乘除的四个接口
function add(a, b) {
return operation(a, b, "add");
}
function subtract(a, b) {
return operation(a, b, "subtract");
}
function multiply(a, b) {
return operation(a, b, "multiply");
}
function divide(a, b) {
return operation(a, b, "divide");
}
// exports
return {
add: add,
subtract: subtract,
multiply: multiply,
divide: divide
};
})();
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment