Skip to content

老破项目相关

💩

交互相关

js
// plugins/index.js
export default {
  install(Vue) {
    // 页签操作
    Vue.prototype.$tab = tab;
    // 认证对象
    Vue.prototype.$auth = auth;
    // 模态框对象
    Vue.prototype.$modal = modal;
  },
};

// this.$model.
modal = {
  // 消息提示
  msg(content) {
    uni.showToast({
      title: content,
      icon: "none",
    });
  },
  // 错误消息
  msgError(content) {
    uni.showToast({
      title: content,
      icon: "error",
    });
  },
  // 成功消息
  msgSuccess(content) {
    uni.showToast({
      title: content,
      icon: "success",
    });
  },
  // 隐藏消息
  hideMsg(content) {
    uni.hideToast();
  },
  // 弹出提示
  alert(content, title) {
    uni.showModal({
      title: title || "系统提示",
      content: content,
      showCancel: false,
    });
  },
  // 确认窗体
  confirm(content, title) {
    return new Promise((resolve, reject) => {
      uni.showModal({
        title: title || "系统提示",
        content: content,
        cancelText: "取消",
        confirmText: "确定",
        success: function (res) {
          if (res.confirm) {
            resolve(res.confirm);
          }
          if (res.cancel) {
            reject(res.cancel);
          }
        },
      });
    });
  },
  // 提示信息
  showToast(option) {
    if (typeof option === "object") {
      uni.showToast(option);
    } else {
      uni.showToast({
        title: option,
        icon: "none",
        duration: 2500,
      });
    }
  },
  // 打开遮罩层
  loading(content) {
    uni.showLoading({
      title: content,
      icon: "none",
    });
  },
  // 关闭遮罩层
  closeLoading() {
    uni.hideLoading();
  },
};

技术相关

复用组件

https://developers.weixin.qq.com/doc/offiaccount/Getting_Started/Overview.html

vue2 文档 https://v2.cn.vuejs.org/v2/guide/

css
.some {
  background-color: #f1f5fb;
  min-height: 100%;
  padding: 12px;

  display: flex;
  flex-direction: column;
  gap: 12px;
}
vue
<template>
  <view></view>
</template>

<script>
export default {
  props: [""],
  components: {},
  data() {
    return {};
  },
  onLoad() {},
  computed: {},
  methods: {},
};
</script>

<style scoped lang="scss"></style>