推拿小程序前端代码仓库
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.

80 lines
1.7 KiB

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