珠宝小程序前端代码
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.

76 lines
1.6 KiB

3 months ago
3 months ago
3 months ago
3 months ago
3 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. console.log('支付成功',res);
  51. success(res)
  52. },
  53. fail: function (err) {
  54. console.log('支付失败',err);
  55. error(err)
  56. uni.showToast({
  57. icon:'none',
  58. title:"支付失败"
  59. })
  60. }
  61. });
  62. })
  63. }