main.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import Vue from 'vue';
  2. import App from './App';
  3. import contactButton from "@/components/contact-button/index";
  4. import cart from '@/components/shopping-cart/index';
  5. import updateUserinfo from '@/components/update-userinfo/index';
  6. import privacy from '@/components/privacy/index';
  7. import simplePhone from "@/components/simple-phone/index";
  8. import wxShare from './components/wx-share/share.vue'
  9. import {wxAuthorize} from './utils/wx-gz-authorize.js'
  10. import 'uni-js-bridge'
  11. Vue.prototype.wxOauth=wxAuthorize;
  12. Vue.config.productionTip = false;
  13. Vue.component("contact-button", contactButton);
  14. Vue.component("cart", cart);
  15. Vue.component("update-userinfo", updateUserinfo);
  16. Vue.component("privacy", privacy);
  17. Vue.component("simple-phone", simplePhone);
  18. Vue.component("wx-share", wxShare);
  19. import action from "@/action_sdk/actionTemplete.js"
  20. Vue.mixin(action)
  21. import h5Templete from "@/utils/h5Templete.js"
  22. Vue.mixin(h5Templete)
  23. Vue.mixin({
  24. methods: {
  25. setData: function(obj, callback) {
  26. let that = this;
  27. const handleData = (tepData, tepKey, afterKey) => {
  28. tepKey = tepKey.split('.');
  29. tepKey.forEach(item => {
  30. if (tepData[item] === null || tepData[item] === undefined) {
  31. let reg = /^[0-9]+$/;
  32. tepData[item] = reg.test(afterKey) ? [] : {};
  33. tepData = tepData[item];
  34. } else {
  35. tepData = tepData[item];
  36. }
  37. });
  38. return tepData;
  39. };
  40. const isFn = function(value) {
  41. return typeof value == 'function' || false;
  42. };
  43. Object.keys(obj).forEach(function(key) {
  44. let val = obj[key];
  45. key = key.replace(/\]/g, '').replace(/\[/g, '.');
  46. let front, after;
  47. let index_after = key.lastIndexOf('.');
  48. if (index_after != -1) {
  49. after = key.slice(index_after + 1);
  50. front = handleData(that, key.slice(0, index_after), after);
  51. } else {
  52. after = key;
  53. front = that;
  54. }
  55. if (front.$data && front.$data[after] === undefined) {
  56. Object.defineProperty(front, after, {
  57. get() {
  58. return front.$data[after];
  59. },
  60. set(newValue) {
  61. front.$data[after] = newValue;
  62. that.$forceUpdate();
  63. },
  64. enumerable: true,
  65. configurable: true
  66. });
  67. front[after] = val;
  68. } else {
  69. that.$set(front, after, val);
  70. }
  71. });
  72. // this.$forceUpdate();
  73. isFn(callback) && this.$nextTick(callback);
  74. }
  75. }
  76. });
  77. App.mpType = 'app';
  78. const app = new Vue({
  79. ...App
  80. });
  81. app.$mount();