爱简收旧衣按件回收前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.8 KiB

1 week ago
3 weeks ago
1 week ago
3 weeks ago
1 week ago
3 weeks ago
1 week ago
3 weeks ago
1 week ago
3 weeks ago
1 week ago
3 weeks ago
  1. // global.js
  2. import util from './utils.js'
  3. import time from './timeUtils.js'
  4. import authorize from './authorize.js'
  5. import md5 from './lib/md5.js'
  6. import Oss from '@/utils/oss-upload/oss/index.js'
  7. import { handleTree } from './tree.js'
  8. // #ifdef H5
  9. // import jWeixin from './lib/jweixin-module.js'
  10. // import { wxPay } from './pay.js'
  11. // #endif
  12. export default function setupGlobalProperties(app) {
  13. // #ifdef H5
  14. // app.config.globalProperties.$jWeixin = jWeixin
  15. // app.config.globalProperties.$wxPay = wxPay
  16. // #endif
  17. app.config.globalProperties.$handleTree = handleTree
  18. app.config.globalProperties.$Oss = Oss
  19. app.config.globalProperties.$authorize = authorize
  20. app.config.globalProperties.$timeUtils = time
  21. app.config.globalProperties.$utils = util
  22. app.config.globalProperties.$md5 = md5
  23. app.config.globalProperties.previewImage = (urls, current) => {
  24. uni.previewImage({
  25. urls,
  26. current,
  27. })
  28. }
  29. app.config.globalProperties.openLocation = (latitude, longitude) => {
  30. if (!latitude || !longitude) return
  31. uni.openLocation({
  32. latitude: Number(latitude),
  33. longitude: Number(longitude),
  34. })
  35. }
  36. // 封装微信支付
  37. uni.requestPaymentWxPay = function (res) {
  38. return new Promise((success, error) => {
  39. uni.requestPayment({
  40. provider: 'wxpay',
  41. timeStamp: res.result.timeStamp,
  42. nonceStr: res.result.nonceStr,
  43. package: res.result.packageValue,
  44. signType: res.result.signType,
  45. paySign: res.result.paySign,
  46. success: function (res) {
  47. console.log('支付成功', res)
  48. success(res)
  49. },
  50. fail: function (err) {
  51. console.log('支付失败', err)
  52. error(err)
  53. uni.showToast({
  54. icon: 'none',
  55. title: '支付失败'
  56. })
  57. }
  58. })
  59. })
  60. }
  61. }