| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- const fs = require('fs');
- const path = 'd:/front-end/hdApp/src/pagesPurchase/order.vue';
- let content = fs.readFileSync(path, 'utf8');
- content = content.replace(
- /<block v-else>[\s\S]*?<\/uni-popup>\s*\n\n\n <\/view>\n<\/template>/,
- `<block v-else>
- <purchase-ghs-panel ref="ghsPanel" :statusBarHeight="statusBarHeight" />
- </block>
- </view>
- </template>`
- );
- content = content.replace(
- /(<style lang="scss" scoped>[\s\S]*?\.login-register-link \{[\s\S]*?\})\s*\.order-page[\s\S]*<\/style>/,
- '$1\n</style>'
- );
- const scriptStart = content.indexOf('<script>');
- const styleStart = content.indexOf('<style');
- const newScript = `<script>
- import { mapGetters } from "vuex";
- import { getWeixinId } from "@/api/invite";
- import autoUpdateMixins from "@/mixins/autoUpdate";
- import PurchaseGhsPanel from "@/admin/home/components/purchase-ghs-panel.vue";
- import { iconSrc } from "@/utils/iconSrc";
- export default {
- name: "purchaseOrder",
- components: { PurchaseGhsPanel },
- mixins: [autoUpdateMixins],
- data() {
- return {
- constant: this.$constant,
- getappIdList: {},
- loginStyle: 0,
- statusBarHeight: 0
- };
- },
- computed: {
- ...mapGetters({ loginInfo: "getLoginInfo" })
- },
- watch: {
- loginInfo(newVal) {
- if (!this.$util.isEmpty(newVal.admin) && newVal.admin.currentShopId > 0) {
- this.handleLoginStyle();
- }
- }
- },
- onPullDownRefresh() {
- if (this.loginStyle === 1 && this.$refs.ghsPanel) {
- this.$refs.ghsPanel.handlePullDownRefresh();
- return;
- }
- uni.stopPullDownRefresh();
- },
- onLoad() {
- try {
- const systemInfo = uni.getSystemInfoSync();
- this.statusBarHeight = systemInfo.statusBarHeight || 0;
- } catch (e) {
- this.statusBarHeight = 0;
- }
- getWeixinId().then(res => {
- this.getappIdList = res.data;
- });
- },
- onShow() {
- if (!this.$util.isEmpty(this.loginInfo.admin) && this.loginInfo.admin.currentShopId > 0) {
- this.handleLoginStyle();
- this.$nextTick(() => {
- if (this.$refs.ghsPanel) {
- this.$refs.ghsPanel.handlePageShow();
- }
- });
- } else {
- this.loginStyle = 0;
- }
- },
- onShareAppMessage(res) {
- if (this.$refs.ghsPanel) {
- const msg = this.$refs.ghsPanel.getShareMessage(res);
- if (msg) return msg;
- }
- return { title: "花掌柜,花店管家婆", desc: "", imageUrl: "", path: "pagesPurchase/order" };
- },
- methods: {
- iconSrc,
- buyItem() {
- const that = this;
- // #ifdef MP-WEIXIN
- uni.navigateToMiniProgram({
- appId: that.getappIdList.mall.miniAppId,
- path: "pages/home/recent",
- envVersion: process.env.NODE_ENV === "development" ? "develop" : "release",
- extraData: {},
- success() {}
- });
- // #endif
- // #ifdef APP-PLUS
- that.$msg("请用微信打开");
- // #endif
- },
- handleLoginStyle() {
- this.loginStyle = 1;
- this.$nextTick(() => {
- if (this.$refs.ghsPanel) {
- this.$refs.ghsPanel.toRemindCustom();
- }
- });
- }
- }
- };
- </script>
- `;
- const stylePart = content.slice(styleStart);
- content = content.slice(0, scriptStart) + newScript + stylePart;
- fs.writeFileSync(path, content);
- console.log('trimmed order.vue');
|