소스 검색

+ 个人行程功能页面

chen.cheng 11 달 전
부모
커밋
6a6093ca82

+ 9 - 0
common/api.js

@@ -95,3 +95,12 @@ export const usrUnCollect = (param) => {
   return http.post(
     `/cp/contentInfo/${openId}/uncollect`, param);
 };
+
+export const fetchUsrTrip = () => {
+  const openId = getUserInfo().openId;
+  return http.get(`/cp/usr/trip/${openId}`, {
+    header: {
+      Authorization: `Bearer ${getToken()}`,
+    },
+  });
+};

+ 12 - 0
pages.json

@@ -91,6 +91,18 @@
           }
         }
       ]
+    },
+    {
+      "root": "pasb",
+      "name": "sub-7",
+      "pages": [
+        {
+          "path": "pages/usr-trip/index",
+          "style": {
+            "navigationBarTitleText": "交通指引"
+          }
+        }
+      ]
     }
   ],
   "globalStyle": {

+ 24 - 2
pages/tabbar/my/index.vue

@@ -4,7 +4,7 @@
       </view>
       <view class="ctl-container">
         <view class="user-info-content">
-          <view class="user-info-img">
+          <view class="user-info-img" @click="handClick">
             <u-avatar :src=" userInfo && userInfo.avatarUrl || ''" shape="circle" :size="60"></u-avatar>
           </view>
           <view class="user-info" @click="$u.throttle(onHeadClick,500)">
@@ -43,7 +43,7 @@
 import { fetchViewCfgList } from '@/common/api';
 import { COMP_CODE } from '@/common/EnumConst';
 import AuthWrap from '@/components/AuthComp/index.vue';
-import { authLogin, getImageUrl, getUserInfo } from '@/util';
+import { authLogin, exit, getImageUrl, getUserInfo } from '@/util';
 
 export default {
   components: { AuthWrap },
@@ -69,6 +69,28 @@ export default {
         this.userInfo = getUserInfo();
       });
     },
+    // 单击或双击
+    handClick(index) {
+      let _this = this;
+      let curTime = new Date().getTime();
+      let lastTime = _this.lastTapDiffTime;
+      _this.lastTapDiffTime = curTime;
+      //两次点击间隔小于300ms, 认为是双击
+      let diff = curTime - lastTime;
+      if (diff < 300) {
+        console.log('双击');
+        //_this.handleVideo('screen',index)自定义事件
+        clearTimeout(_this.lastTapTimeoutFunc); // 成功触发双击事件时,取消单击事件的执行
+        exit();
+        authLogin();
+      } else {
+        // 单击事件延时300毫秒执行
+        _this.lastTapTimeoutFunc = setTimeout(function () {
+          console.log('单击');
+          //_this.handleVideo('playOrStop',index)自定义事件
+        }, 300);
+      }
+    },
     onItemClick(item) {
       if (item.url) {
         uni.navigateTo({

+ 2 - 0
pages/tabbar/news/index.vue

@@ -21,6 +21,7 @@
 
 <script>
 import { fetchContentInfo } from '@/common/api';
+import { CONTENT_TYPE } from '@/common/EnumConst';
 import ItemList from '@/components/ItemList/index.vue';
 import { getImageUrl } from '@/util';
 
@@ -44,6 +45,7 @@ export default {
       const res = await fetchContentInfo({
         pageNum: 1,
         pageSize: 99,
+        contentType: CONTENT_TYPE.news,
         title: this.keyword,
       });
       if (res.rows.length > 0) {

+ 5 - 0
pasb/pages/component/RichText/index.scss

@@ -0,0 +1,5 @@
+.ql-align-center {
+  display: flex;
+  align-items: center;
+  justify-content: center;
+}

+ 62 - 0
pasb/pages/component/RichText/index.vue

@@ -0,0 +1,62 @@
+<template>
+  <mp-html :content="content|formatRichText" selectable="true" show-img-menu="true" ref="mpHtml" />
+</template>
+
+<script>
+export default {
+  name: 'rich-text',
+  props: {
+    content: {
+      type: String,
+      default: '',
+    },
+  },
+  data() {
+    return {};
+  },
+  created() {
+  },
+  filters: {
+    /**
+     * 处理富文本里的图片宽度自适应
+     * 1.去掉img标签里的style、width、height属性
+     * 2.img标签添加style属性:max-width:100%;height:auto
+     * 3.修改所有style里的width属性为max-width:100%
+     * 4.去掉<br/>标签
+     * @param html
+     * @returns {void|string|*}
+     *
+     */
+    formatRichText(html) { //控制小程序中图片大小
+      let newContent = html.replace(/<img[^>]*>/gi, function (match, capture) {
+        match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
+        match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
+        match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
+        return match;
+      });
+      newContent = newContent.replace(/style="[^"]+"/gi, function (match, capture) {
+        match = match.replace(/width:[^;]+;/gi, 'max-width:100%;').replace(/width:[^;]+;/gi,
+            'max-width:100%;');
+        return match;
+      });
+      newContent = newContent.replace(/<br[^>]*\/>/gi, '');
+      newContent = newContent.replace(/<img src="\/dev-api|<img src="\/prod-api/gi,
+          `<img style="max-width:100%;height:auto;display:inline-block;margin:10rpx auto;" src="${process.env.UNI_FILE_PREFIX}`);
+
+      newContent = newContent.replace(/<iframe(([\s\S])*?)<\/iframe>/ig, function (match, capture) {
+        match = match.replace('iframe', 'video');
+        match = match.replace(/<video/gi,
+            '<video style="width:100%;height:auto;display:inline-block;margin:10rpx auto;"')
+            .replace(/style='[^']+'/gi, 'style=\'max-width:100%;height:auto;display:inline-block;margin:10rpx auto;\'');
+        match = match.replace(/src="/gi, `src="${process.env.UNI_FILE_PREFIX}`)
+            .replace(/src='/gi, `src='${process.env.UNI_FILE_PREFIX}`);
+        return match;
+      });
+      return newContent;
+    },
+  },
+  methods: {
+  },
+};
+</script>
+<style lang="scss" src="./index.scss" />;

+ 3 - 40
pasb/pages/detail/index.vue

@@ -4,7 +4,7 @@
       <view class="title-content-text">{{ title }}</view>
       <view class="title-content-date">{{ date }}</view>
     </view>
-    <mp-html :content="content|formatRichText" selectable="true" show-img-menu="true" />
+    <rich-text :content="content"></rich-text>
     <view class="content-like-col" v-if="CONTENT_TYPE.news === contentType">
       <view class="icon-wrap">
         <u-icon
@@ -29,10 +29,12 @@
 <script>
 import { fetchContentDetail, fetchUsrContent, usrCollect, usrLike, usrUnCollect, usrUnLike } from '@/common/api';
 import { CONTENT_TYPE } from '@/common/EnumConst';
+import RichText from '@/pasb/pages/component/RichText/index.vue';
 import { authLogin, getUserInfo } from '@/util';
 
 export default {
   name: 'content',
+  components: { RichText },
   props: {},
   data() {
     return {
@@ -59,45 +61,6 @@ export default {
     this.getContentInfo();
     this.getUsrContent();
   },
-  filters: {
-    /**
-     * 处理富文本里的图片宽度自适应
-     * 1.去掉img标签里的style、width、height属性
-     * 2.img标签添加style属性:max-width:100%;height:auto
-     * 3.修改所有style里的width属性为max-width:100%
-     * 4.去掉<br/>标签
-     * @param html
-     * @returns {void|string|*}
-     *
-     */
-    formatRichText(html) { //控制小程序中图片大小
-      let newContent = html.replace(/<img[^>]*>/gi, function (match, capture) {
-        match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
-        match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
-        match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
-        return match;
-      });
-      newContent = newContent.replace(/style="[^"]+"/gi, function (match, capture) {
-        match = match.replace(/width:[^;]+;/gi, 'max-width:100%;').replace(/width:[^;]+;/gi,
-            'max-width:100%;');
-        return match;
-      });
-      newContent = newContent.replace(/<br[^>]*\/>/gi, '');
-      newContent = newContent.replace(/<img src="\/dev-api/gi,
-          `<img style="max-width:100%;height:auto;display:inline-block;margin:10rpx auto;" src="${process.env.UNI_FILE_PREFIX}`);
-
-      newContent = newContent.replace(/<iframe(([\s\S])*?)<\/iframe>/ig, function (match, capture) {
-        match = match.replace('iframe', 'video');
-        match = match.replace(/<video/gi,
-            '<video style="width:100%;height:auto;display:inline-block;margin:10rpx auto;"')
-            .replace(/style='[^']+'/gi, 'style=\'max-width:100%;height:auto;display:inline-block;margin:10rpx auto;\'');
-        match = match.replace(/src="/gi, `src="${process.env.UNI_FILE_PREFIX}`)
-            .replace(/src='/gi, `src='${process.env.UNI_FILE_PREFIX}`);
-        return match;
-      });
-      return newContent;
-    },
-  },
   methods: {
     async getContentInfo() {
       const {

+ 0 - 1
pasb/pages/login/index.vue

@@ -17,7 +17,6 @@
       ></u--input>
     </view>
 
-
     <button class="login-btn" open-type="getUserInfo" @getuserinfo="getUserInfo">
       <u-icon name="weixin-fill" color="#fefefe" size="28"></u-icon>
       一键微信登录

+ 16 - 0
pasb/pages/usr-trip/index.scss

@@ -0,0 +1,16 @@
+@import "../../../common/common.scss";
+.usr-trip-info-container {
+  padding: 40rpx 0;
+  box-sizing: border-box;
+  height: 100%;
+  width: 90%;
+}
+
+.auth-wrap{
+  width: 100%;
+  height: 100%;
+  display: flex;
+  align-items: center;
+  flex-direction: column;
+  justify-content: flex-start;
+}

+ 56 - 0
pasb/pages/usr-trip/index.vue

@@ -0,0 +1,56 @@
+<template>
+  <auth-wrap  ref="authWrap">
+    <template class="usr-trip-info-container" slot="content">
+      <rich-text :content="content" v-if="content"></rich-text>
+      <u-empty
+          v-else
+          mode="data"
+          text="还没有添加行程,赶紧去报名吧!"
+          @click="regisClick"
+      >
+      </u-empty>
+    </template>
+  </auth-wrap>
+</template>
+
+<script>
+import { fetchUsrTrip } from '@/common/api';
+import AuthWrap from '@/components/AuthComp/index.vue';
+import ItemList from '@/components/ItemList/index.vue';
+import RichText from '@/pasb/pages/component/RichText/index.vue';
+
+export default {
+  components: {
+    RichText,
+    AuthWrap,
+    ItemList,
+  },
+  data() {
+    return {
+      content: '',
+    };
+  },
+  onLoad() {
+    this.$refs.authWrap.reloadPage();
+    this.loadmore();
+  },
+  methods: {
+    async loadmore() {
+      const { data } = await fetchUsrTrip();
+      this.content = data.tripDetail;
+    },
+    regisClick() {
+      uni.navigateTo({
+        url: '/pasb/pages/regis/index',
+      });
+    },
+  },
+  onShareAppMessage() {
+    return {
+      title: 'First UI组件库',
+    };
+  },
+};
+</script>
+
+<style lang="scss" src="./index.scss" />

+ 3 - 0
util/index.js

@@ -68,6 +68,9 @@ export const getUserInfo = () => {
 export const setUserInfo = (userInfo) => {
   setStorageObj('userInfo', userInfo);
 };
+export const exit = () => {
+  uni.clearStorageSync();
+};
 export const getToken = () => {
   const token = getStorageObj('token');
   if (!token) {