Преглед на файлове

🐞 fix: 详情点击修改

wolyshaw преди 2 години
родител
ревизия
d6062d6777
променени са 5 файла, в които са добавени 75 реда и са изтрити 51 реда
  1. 22 2
      src/student/music/album-detail/index.tsx
  2. 2 12
      src/student/music/list/index.tsx
  3. 5 4
      src/student/music/list/item.tsx
  4. 45 32
      src/student/music/music.ts
  5. 1 1
      vite.config.ts

+ 22 - 2
src/student/music/album-detail/index.tsx

@@ -10,10 +10,19 @@ import FavoritedIcon from '../album/favorited.svg'
 import styles from './index.module.less'
 import Item from '../list/item'
 import { useRect } from '@vant/use'
+import { musicBuy } from '../music'
+
+const noop = () => {}
 
 export default defineComponent({
   name: 'AlbumDetail',
-  setup() {
+  props: {
+    onItemClick: {
+      type: Function,
+      default: noop
+    }
+  },
+  setup({ onItemClick }) {
     const params = reactive({
       search: '',
       page: 1
@@ -134,7 +143,18 @@ export default defineComponent({
             onLoad={FetchList}
           >
             {data.value && data.value.rows.length
-              ? data.value.rows.map(item => <Item data={item} />)
+              ? data.value.rows.map(item => (
+                  <Item
+                    data={item}
+                    onClick={() => {
+                      if (onItemClick === noop || !onItemClick) {
+                        musicBuy(item)
+                      } else {
+                        onItemClick(item)
+                      }
+                    }}
+                  />
+                ))
               : null}
           </List>
         </div>

+ 2 - 12
src/student/music/list/index.tsx

@@ -7,8 +7,7 @@ import SelectTag from '../search/select-tag'
 import { useRoute, useRouter } from 'vue-router'
 import ColResult from '@/components/col-result'
 import styles from './index.module.less'
-import { postMessage } from '@/helpers/native-message'
-// import { musicBuy } from '../music'
+import { musicBuy } from '../music'
 
 const noop = () => {}
 
@@ -122,16 +121,7 @@ export default defineComponent({
                   data={item}
                   onClick={() => {
                     if (onItemClick === noop) {
-                      postMessage({
-                        api: 'openAccompanyWebView',
-                        content: {
-                          url: location.origin + '/accompany?id=' + item.id,
-                          orientation: 0,
-                          isHideTitle: true,
-                          statusBarTextColor: false,
-                          isOpenLight: true
-                        }
-                      })
+                      musicBuy(item)
                     } else {
                       onItemClick(item)
                     }

+ 5 - 4
src/student/music/list/item.tsx

@@ -22,11 +22,12 @@ export default defineComponent({
       default: {}
     },
     onClick: {
-      type: Function,
-      default: (item: any) => {}
+      type: Function
     }
   },
-  setup({ data, onClick }) {
+  setup({ onClick, data }, { emit }) {
+    // const data = props.data
+    // console.log(props, emit)
     const favorite = ref(data.favorite)
     const favoriteLoading = ref(false)
 
@@ -43,7 +44,7 @@ export default defineComponent({
       <div
         class={styles.item}
         onClick={() => {
-          onClick(data)
+          onClick?.(data)
         }}
       >
         <header class={styles.header}>

+ 45 - 32
src/student/music/music.ts

@@ -1,32 +1,45 @@
-import { orderStatus } from '@/views/order-detail/orderStatus'
-import { Dialog } from 'vant'
-
-export const musicBuy = (item: any, callBack?: any) => {
-  // play :0 不能看,1 能看
-  const path =
-    !item.play && item.chargeType === 'VIP' ? '/memberCenter' : '/orderDetail'
-  if (!item.play && item.chargeType === 'VIP') {
-    Dialog.confirm({
-      title: '提示',
-      message: '您还不是会员,是否加入会员?',
-      confirmButtonColor: 'var(--van-primary)'
-    }).then(() => {
-      callBack && callBack(path)
-    })
-    return
-  } else if (!item.play && item.chargeType === 'CHARGE') {
-    orderStatus.orderObject.orderType = 'MUSIC'
-    orderStatus.orderObject.orderName = item.musicSheetName
-    orderStatus.orderObject.orderDesc = item.musicSheetName
-    orderStatus.orderObject.actualPrice = item.musicPrice
-    orderStatus.orderObject.orderList = [
-      {
-        orderType: 'MUSIC',
-        goodsName: item.musicSheetName,
-        actualPrice: item.musicPrice,
-        ...item
-      }
-    ]
-    callBack && callBack(path)
-  }
-}
+import { orderStatus } from '@/views/order-detail/orderStatus'
+import { postMessage } from '@/helpers/native-message'
+import { Dialog } from 'vant'
+
+export const musicBuy = (item: any, callBack?: any) => {
+  postMessage({
+    api: 'openAccompanyWebView',
+    content: {
+      // url: location.origin + '/accompany?id=' + item.id,
+      url: 'http://192.168.3.13:3000/colexiu.html?id=' + item.id,
+      orientation: 0,
+      isHideTitle: true,
+      statusBarTextColor: false,
+      isOpenLight: true
+    }
+  })
+  return
+  // play :0 不能看,1 能看
+  const path =
+    !item.play && item.chargeType === 'VIP' ? '/memberCenter' : '/orderDetail'
+  if (!item.play && item.chargeType === 'VIP') {
+    Dialog.confirm({
+      title: '提示',
+      message: '您还不是会员,是否加入会员?',
+      confirmButtonColor: 'var(--van-primary)'
+    }).then(() => {
+      callBack && callBack(path)
+    })
+    return
+  } else if (!item.play && item.chargeType === 'CHARGE') {
+    orderStatus.orderObject.orderType = 'MUSIC'
+    orderStatus.orderObject.orderName = item.musicSheetName
+    orderStatus.orderObject.orderDesc = item.musicSheetName
+    orderStatus.orderObject.actualPrice = item.musicPrice
+    orderStatus.orderObject.orderList = [
+      {
+        orderType: 'MUSIC',
+        goodsName: item.musicSheetName,
+        actualPrice: item.musicPrice,
+        ...item
+      }
+    ]
+    callBack && callBack(path)
+  }
+}

+ 1 - 1
vite.config.ts

@@ -12,7 +12,7 @@ function resolve(dir: string) {
 // https://vitejs.dev/config/
 // https://github.com/vitejs/vite/issues/1930 .env
 // const proxyUrl = 'https://mstutest.dayaedu.com/';
-const proxyUrl = 'http://dev.colexiu.com/'
+const proxyUrl = 'https://dev.colexiu.com/'
 export default defineConfig({
   base: './',
   plugins: [