敢为人鲜小程序前端代码仓库
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.

78 lines
1.7 KiB

11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
  1. import Vue from 'vue'
  2. import util from './utils.js'
  3. import time from './timeUtils.js'
  4. import authorize from './authorize.js'
  5. import 'dayjs/locale/zh-cn'
  6. import dayjs from 'dayjs'
  7. import md5 from './lib/md5.js'
  8. // #ifdef H5
  9. import jWeixin from './lib/jweixin-module.js'
  10. import { wxPay } from './pay.js'
  11. Vue.prototype.$jWeixin = jWeixin
  12. Vue.prototype.$wxPay = wxPay
  13. // #endif
  14. dayjs.locale('zh-cn')
  15. import Oss from '@/utils/oss-upload/oss/index.js'
  16. import { handleTree } from './tree.js'
  17. Vue.prototype.$handleTree = handleTree
  18. Vue.prototype.$Oss = Oss
  19. Vue.prototype.$dayjs = dayjs
  20. Vue.prototype.$authorize = authorize
  21. Vue.prototype.$timeUtils = time
  22. Vue.prototype.$utils = util
  23. Vue.prototype.$md5 = md5
  24. Vue.prototype.previewImage = (urls, current) => {
  25. uni.previewImage({
  26. urls,
  27. current,
  28. })
  29. }
  30. Vue.prototype.openLocation = (latitude, longitude) => {
  31. if(!latitude || !longitude){
  32. return
  33. }
  34. uni.openLocation({
  35. latitude : Number(latitude),
  36. longitude : Number(longitude),
  37. })
  38. }
  39. // 封装微信支付
  40. uni.requestPaymentWxPay = function(res){
  41. return new Promise((success, error) => {
  42. uni.requestPayment({
  43. provider: 'wxpay', // 服务提提供商
  44. timeStamp: res.result.timeStamp, // 时间戳
  45. nonceStr: res.result.nonceStr, // 随机字符串
  46. package: res.result.packageValue,
  47. signType: res.result.signType, // 签名算法
  48. paySign: res.result.paySign, // 签名
  49. success: function (res) {
  50. uni.showToast({
  51. title: '支付成功',
  52. icon: 'success'
  53. })
  54. success(res)
  55. },
  56. fail: function (err) {
  57. console.log('支付失败',err);
  58. error(err)
  59. uni.showToast({
  60. icon:'none',
  61. title:"支付失败"
  62. })
  63. }
  64. });
  65. })
  66. }