<代码收藏>动态生成数组

本文转自:http://blog.youkuaiyun.com/zhy_cheng/article/details/10813573
[cpp]  view plain copy
  1. #include <iostream>  
  2. #include <ctime>  
  3. #include <cstdlib>  
  4. using namespace std;  
  5.    
  6. void oneArray()  
  7. {  
  8.        
  9.     int size=rand()%10;  
  10.     int* pint=new int[size];  
  11.     for(int i=0;i<size;++i)  
  12.     {  
  13.         pint[i]=rand()%100;  
  14.     }  
  15.     cout<<"one array is "<<endl;  
  16.     for(int i=0;i<size;++i)  
  17.     {  
  18.         cout<<pint[i]<<"\t";  
  19.     }  
  20.     cout<<endl;  
  21.     delete []pint;  
  22. }  
  23.    
  24. void twoArray()  
  25. {  
  26.     int row=rand()%10;  
  27.     int column=rand()%10;  
  28.     cout<<"row is "<<row<<" column is "<<column<<endl;  
  29.     cout<<"two array is"<<endl;  
  30.     int** p=new int*[row];  
  31.     for(int i=0;i<row;++i)  
  32.     {  
  33.         p[i]=new int[column];  
  34.     }  
  35.     for(int i=0;i<row;++i)  
  36.     {  
  37.         for(int j=0;j<column;++j)  
  38.         {  
  39.             p[i][j]=rand()%100;  
  40.         }  
  41.     }  
  42.        
  43.     for(int i=0;i<row;++i)  
  44.     {  
  45.         for(int j=0;j<column;++j)  
  46.         {  
  47.             cout<<p[i][j]<<"\t";  
  48.         }  
  49.         cout<<endl;  
  50.     }  
  51.     cout<<"delete array"<<endl;  
  52.     for(int i=0;i<row;++i)  
  53.     {  
  54.         delete []p[i];  
  55.     }  
  56.     delete []p;  
  57. }  
  58. void threeArray()  
  59. {  
  60.     cout<<"three array"<<endl;  
  61.     int height=rand()%10;  
  62.     int row=rand()%10;  
  63.     int column=rand()%10;  
  64.     cout<<"height is "<<height<<" row is "<<row<<" column is "<<column<<endl;  
  65.     int*** p=new int**[height];  
  66.     for(int i=0;i<height;i++)  
  67.     {  
  68.         p[i]=new int*[row];  
  69.     }  
  70.     for(int i=0;i<height;++i)  
  71.     {  
  72.         for(int j=0;j<row;++j)  
  73.         {  
  74.             p[i][j]=new int[column];  
  75.         }  
  76.     }  
  77.    
  78.     for(int i=0;i<height;++i)  
  79.         for(int j=0;j<row;++j)  
  80.             for(int k=0;k<column;++k)  
  81.             {  
  82.                 p[i][j][k]=rand()%100;  
  83.             }  
  84.    
  85.     for(int i=0;i<height;++i)  
  86.     {  
  87.         for(int j=0;j<row;++j)  
  88.         {  
  89.             for(int k=0;k<column;++k)  
  90.             {  
  91.                 cout<<p[i][j][k]<<"\t";  
  92.             }  
  93.             cout<<endl;  
  94.         }  
  95.         cout<<endl<<endl;  
  96.     }  
  97.     cout<<"delete three array"<<endl;  
  98.     for(int i=0;i<height;++i)  
  99.     {  
  100.         for(int j=0;j<row;++j)  
  101.         {  
  102.             delete []p[i][j];  
  103.         }  
  104.     }  
  105.     for(int i=0;i<height;i++)  
  106.     {  
  107.         delete []p[i];  
  108.     }  
  109.     delete []p;  
  110. }  
  111.    
  112.    
  113. void main()  
  114. {  
  115.     srand(unsigned(time(NULL)));  
  116.     oneArray();  
  117.     twoArray();  
  118.     threeArray();  
  119.     int aa;  
  120.     cin>>aa;  
  121. }  
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> <link rel="stylesheet" type="text/css" href="css/bootstrap.css" /> <link rel="stylesheet" type="text/css" href="css/bootstrap-icons.css" /> <link rel="stylesheet" href="css/style.css" /> <link rel="stylesheet" href="css/table.css" /> <style> .bg-f4f6f7 { background-color: #f4f6f7; } </style> </head> <body> <div> <div class="bg-primary d-flex justify-content-between align-items-center row p-3"> <div class="h1 text-white ml-5">Æon</div> <div class="row mr-5"> <img src="img/管理员.png" class="gly mr-1" /> <div>管理员</div> </div> </div> <div class="row bg-f4f6f7"> <div class="sidebar"> <ul class="nav flex-column px-2 py-3"> <li class="nav-item"> <a class="nav-link " href="#" data-template="home"> 首页 </a> </li> <!-- 用户管理 --> <li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false"> 用户管理 </a> <ul class="dropdown-menu" aria-labelledby="userDropdown"> <li><a class="dropdown-item" href="#">封禁/解除用户</a></li> <li><a class="dropdown-item" href="#" data-template="users">用户列表</a></li> <li><a class="dropdown-item" href="#">用户行为记录</a></li> </ul> </li> <!-- 歌手管理 --> <li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" href="#" id="singerDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false"> 歌手管理 </a> <ul class="dropdown-menu" aria-labelledby="singerDropdown"> <li><a class="dropdown-item" href="#">封禁/解封歌手</a></li> <li><a class="dropdown-item" href="#" data-template="geshou">歌手歌曲</a></li> </ul> </li> <!-- 歌曲内容管理 --> <li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" href="#" id="songDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false"> 歌曲内容管理 </a> <ul class="dropdown-menu" aria-labelledby="songDropdown"> <li><a class="dropdown-item" href="#">歌曲收藏</a></li> <li><a class="dropdown-item" href="#">评论管理</a></li> <li><a class="dropdown-item" href="#">歌曲信息</a></li> <li><a class="dropdown-item" href="#" data-template="gedan">歌单管理</a></li> </ul> </li> <!-- 社区管理 --> <li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" href="#" id="communityDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false"> 社区管理 </a> <ul class="dropdown-menu" aria-labelledby="communityDropdown"> <li><a class="dropdown-item" href="#" data-template="shequ">帖子审核</a></li> <li><a class="dropdown-item" href="#">帖子发布</a></li> <li><a class="dropdown-item" href="#">举报处理</a></li> </ul> </li> <!-- 数据分析 --> <li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" href="#" id="analysisDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false"> 数据分析 </a> <ul class="dropdown-menu" aria-labelledby="analysisDropdown"> <li><a class="dropdown-item" href="#" data-template="data">播放量分析</a></li> <li><a class="dropdown-item" href="#">用户分析</a></li> </ul> </li> <!-- 管理员管理 --> <li class="nav-item"> <a class="nav-link" href="#" data-template="guanli"> 管理员管理 </a> </li> <!-- 系统管理 --> <li class="nav-item"> <a class="nav-link" href="#"> 系统管理 </a> </li> </ul> </div> <div class="m-2" id="contentArea"></div> </div> <template id="homeTpl" class=""> <div class="daohang"> <h5>首页</h5> </div> <div class="homet"> <div class="hometl"> <h6>用户数量</h6> <div class="yonghu mt-4"> <div>新增用户数<a>{{usernum}}</a></div> <div>总用户数<a>{{totalusernum}}</a></div> </div> </div> <div class="hometr"> <h6>歌手数量</h6> <div class="geshou mt-4"> <div>总歌手数<a>{{singernum}}</a></div> </div> </div> </div> <div class="homeb"> <div class="homebl"> <h6>代办事项</h6> <div class="daiban mt-4"> <div>无</div> </div> </div> <div class="homebr"> <div class="homebrt"> <h6>快捷入口</h6> <div class="d-flex justify-content-around mt-4"> <div class="kuaijie"> <img src="img/管理员.png" style="height: 40px;width: 40px;" /> <div>用户</div> </div> <div class="kuaijie"> <img src="img/管理员.png" style="height: 40px;width: 40px;" /> <div>用户</div> </div> <div class="kuaijie"> <img src="img/管理员.png" style="height: 40px;width: 40px;" /> <div>用户</div> </div> <div class="kuaijie"> <img src="img/管理员.png" style="height: 40px;width: 40px;" /> <div>用户</div> </div> <div class="kuaijie"> <img src="img/管理员.png" style="height: 40px;width: 40px;" /> <div>用户</div> </div> <div class="kuaijie"> <img src="img/管理员.png" style="height: 40px;width: 40px;" /> <div>用户</div> </div> <div class="kuaijie"> <img src="img/管理员.png" style="height: 40px;width: 40px;" /> <div>用户</div> </div> <div class="kuaijie"> <img src="img/管理员.png" style="height: 40px;width: 40px;" /> <div>用户</div> </div> </div> </div> <div class="homebrb"> <h6>访问统计</h6> </div> </div> </div> </template> <template id="usersTpl"> <div class="daohang"> <h5>首页->用户</h5> </div> <div class="user"> <div class="sousuo"> <div>用户名:</div> <input placeholder="查询内容" class="pt-2 pb-2 rounded" /> <div class="border border-secondary rounded p-2">查询</div> </div> <div class="zs"> <div class="border border-secondary rounded p-2">新增</div> <div class="border border-secondary rounded p-2">删除</div> </div> <table id="userTable" style="margin-top: 10px;"> <thead> <tr> <th>选择</th> <th>索引</th> <th>用户名</th> <th>头像</th> <th>性别</th> <th>账号</th> <th>操作</th> </tr> </thead> <tbody id="tableBody"> <!-- 数据将通过JavaScript动态加载 --> </tbody> </table> </div> </template> <template id="singerTpl"> <div class="daohang"> <h5>首页->歌手</h5> </div> <div class="singer"> <div class="sousuo"> <div>歌手/歌曲:</div> <input placeholder="查询内容" class="pt-2 pb-2 rounded" /> <div class="border border-secondary rounded p-2">查询</div> </div> <div class="zs"> <div class="border border-secondary rounded p-2">新增</div> <div class="border border-secondary rounded p-2">删除</div> </div> <table id="userTable" style="margin-top: 10px;"> <thead> <tr> <th><input type="checkbox" id="selectAll" class="checkbox"></th> <th>索引</th> <th>歌手</th> <th>照片</th> <th>性别</th> <th>歌曲</th> <th>操作</th> </tr> </thead> <tbody id="tableBody"> <tr> <td colspan="7" class="loading">加载中...</td> </tr> </tbody> </table> </div> </template> <template id="gedanTpl"> <div class="daohang"> <h5>首页->歌单</h5> </div> <div class="gedan"> <div class="sousuo"> <div>歌单:</div> <input placeholder="查询内容" class="pt-2 pb-2 rounded" /> <div class="border border-secondary rounded p-2">查询</div> </div> <div class="zs"> <div class="border border-secondary rounded p-2">新增</div> <div class="border border-secondary rounded p-2">删除</div> </div> <table id="musicTable" style="margin-top: 10px;"> <thead> <tr> <th>索引</th> <th>歌曲名称</th> <th>海报</th> <th>歌曲分类</th> <th>歌手</th> <th>视频</th> <th>操作</th> </tr> </thead> <tbody id="tableBody"> <tr> <td colspan="7" class="loading">加载中...</td> </tr> </tbody> </table> </div> </template> <template id="shequTpl"> <div class="daohang"> <h5>首页->社区</h5> </div> <div class="shequ"> <div class="sousuo"> <div>歌单:</div> <input placeholder="查询内容" class="pt-2 pb-2 rounded" /> <div class="border border-secondary rounded p-2">查询</div> </div> <div class="zs"> <div class="border border-secondary rounded p-2">新增</div> <div class="border border-secondary rounded p-2">删除</div> </div> <table id="shequTable" style="margin-top: 10px;"> <thead> <tr> <th><input type="checkbox" id="selectAll"></th> <th>编号</th> <th>帖子标题</th> <th>发布人</th> <th>发布时间</th> <th>更新时间</th> <th>审核时间</th> <th>状态</th> <th>操作</th> </tr> </thead> <tbody id="tableBody"> <tr> <td colspan="9" class="loading">加载中...</td> </tr> </tbody> </table> </div> </template> <template id="shujuTpl"> <div class="daohang"> <h5>播放量</h5> </div> <div class="shuju"> <div class="sjl"> <h6>平台总播放量分析</h6> </div> <div class="sjr"> <div class="sjrt"> 歌手播放量 </div> <div class="sjrb"> 当前趋势分析 </div> </div> </div> </template> <template id="guanliTpl"> <div class="daohang"> <h5>管理员管理</h5> </div> <div class="guanliyuan"> <div class="gll"> <h6>管理员</h6> </div> <div class="glr"> </div> </div> </template> </div> <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.js"></script> <script src="js/cebianlan.js"></script> <!-- <script src="js/shequ.js"></script> <script src="js/gedan.js"></script> <script src="js/geshou.js"></script> <script src="js/yonghu.js"></script> --> </body> </html>在js中新增20条用户数据,能够进行增删设置,搜索设置
06-14
import React, { useState, useEffect, useRef } from 'react'; import { Form, Button, Layout, Menu, Select, Input, DatePicker, Breadcrumb, } from '@arco-design/web-react'; import ModoTabs from '@/components/Tabs'; import './style/index.less'; import { IconRefreshColor, IconHeartColor, IconHardDiskColor, IconSortColor, IconShieldStarColor } from 'modo-design/icon'; import Detail from '../ModelManager/pages/Detail'; import { Tag, Face } from 'modo-design'; import { getModelList, getDimByParentCode } from './api'; import { useHistory } from 'react-router-dom'; import modelImg from './images/model.png'; import getAppName from "modo-plugin-common/src/core/src/utils/getAppName"; // import gfm from 'remark-gfm'; import qs from 'qs'; const FormItem = Form.Item; const Header = Layout.Header; const Footer = Layout.Footer; const Content = Layout.Content; const Sider = Layout.Sider; const MenuItem = Menu.Item; const { RangePicker } = DatePicker; const { Option } = Select; const InputSearch = Input.Search; const colors = [ 'arcoblue', 'cyan', 'gray', 'orange', 'purple', 'red', 'orangered', 'gold', 'lime', 'green', 'blue', 'pinkpurple', 'magenta' ]; function ModelSquare (props: any) { const modoTabsRef = useRef(); const [isShowDetails, setIsShowDetails] = useState(false); const [operType, setOperType] = useState('view'); const [modelId, setModelId] = useState(''); const [options, setOptions] = useState([]); const [totalNum, setTotalNum] = useState(0); const [modelList, setModelList] = useState([]); const [tagOptions, setTagOptions] = useState([]); const [activeTag, setActiveTag] = useState(''); const [sortType, setSortType] = useState('-lastupd'); const history = useHistory(); const changeType = (val, color) => { console.log('changeType', val); setActiveTag(`${val}-${color}`); getModels({taskTypeId: `~%${val}%`}); } const toDetails = (val) => { setIsShowDetails(true); setModelId(val.modelId); setOperType('view'); } const toExperience = (e: Event, item: any) => { e.stopPropagation(); const params = { model_id: item.routerId, } const queryString = Object.entries(params) .map(([key, value]) => `${key}=${encodeURIComponent(value as string)}`) .join('&'); const env = process.env.NODE_ENV; const APP_NAME = getAppName(); const path = env === 'production' ? `/${APP_NAME}/frame` : ''; history.push(`${path}/ai_chat_test?${queryString}`); }; const getModels = (val) => { const params = { isPublic: "1", ...val } getModelList({...params}).then(res => { const { data } = res; if (data.success) { const getTag = (tags) => { if (tags && tags.length > 0) { return tags.map((item) => { const t = item.split('-'); return t[t.length - 1] }); } return []; } setTotalNum(data.data.length || 0); const datas = data.data.map(item => { // const taskTypeId = item.taskTypeId ? getTag(item.taskTypeId.split(',')) : []; // const sceneType = data.data.sceneType ? getTag(data.data.sceneType.split(',')) : []; // const systemType = data.data.systemType ? getTag(data.data.systemType.split(',')) : []; // const customizeType = data.data.customizeType ? getTag(data.data.customizeType.split(',')) : []; const taskTypeId = item.taskTypeId ? getTag(item.taskTypeId.split(',')) : []; const sceneType = item.sceneType ? getTag(item.sceneType.split(',')) : []; const systemType = item.systemType ? getTag(item.systemType.split(',')) : []; // const customizeType = data.data.customizeType ? getTag(data.data.customizeType.split(',')) : []; const customizeType = item.customizeType ? item.customizeType.split(',') : []; const aiAndLnTag = []; if(item.aiFramework) { aiAndLnTag.push(item.aiFramework); } if(item.language) { aiAndLnTag.push(item.language); } item.taskTag = taskTypeId; item.sceneTag = sceneType; item.systemTag = systemType; item.customizeTag = customizeType; item.aiAndLnTag = aiAndLnTag; // item.tags = ["文本生成",item.licenseType,item.modelType]; item.tags = taskTypeId; return item; }); setModelList(datas); } }).catch(err => { console.log(err); }) } const getTypes = (val) => { const params = { parentId: "taskType" } getDimByParentCode({...params}).then(res => { let options = res.data.data || []; options.sort((a, b) => Number(a.seq) - Number(b.seq)); setTagOptions(options); }).catch(err => { console.log(err); }) } useEffect(()=>{ getModels({sort: sortType}); getTypes(); }, []); // 未启动 部署失败 运行中 return ( <div className="model-square"> { !isShowDetails && <ModoTabs title="模型库" ref={modoTabsRef} className="model-square-tabs"> <div className="model-square-pane-content"> <Layout> <Sider resizeDirections={['right']} style={{ minWidth: 150, maxWidth: 500, width: 240, height: '100%' }} > <div className="model-square-sider"> <div className="model-square-sider-header"> <div>筛选</div> <Button type="text" onClick={()=>{setActiveTag('');getModels({})}}>清空</Button> </div> <div className="model-square-sider-content"> { tagOptions.map((item, index)=>{ const tags = item.children || []; return <div className="square-sider-content-item"> <div className="square-sider-content-item-title">{item.dimValue}</div> <div className="square-sider-content-item-tag"> {tags.map((tag)=>{ return <Tag className={`${tag.dimValue}-${colors[index]}` === activeTag ? `${colors[index]} active` : `${colors[index]}`} onClick={()=>{changeType(tag.dimValue, colors[index])}} color={colors[index]}>{tag.dimValue}</Tag> })} </div> </div> }) } </div> </div> </Sider> <Content className="model-square-content"> <Layout> <Header className="model-square-content-header"> <div className="content-header-filter"> <InputSearch allowClear placeholder='请输入关键字,进行模型搜索' style={{ width: 300 }} onClear={()=>{getModels({})}} onSearch={(val)=>{getModels({modelLabel: `~%${val}%`})}}/> <Select addBefore={<IconSortColor />} value={sortType} allowClear placeholder='请选择排序类型' style={{ width: 300 }} onClear={()=>{ setSortType(''); getModels({}); }} onChange={(value) =>{ setSortType(value); if(value !== 'all') { getModels({sort: value}) } else { getModels({}) } }} > <Select.OptGroup label={`排序类型`} key={1}> <Option key={'all'} value={'all'}> {'综合排序'} </Option> <Option key={'-favCnt'} value={'-favCnt'}> {'收藏量'} </Option> </Select.OptGroup> <Select.OptGroup label={`正序倒序`} key={2}> <Option key={'-lastupd'} value={'-lastupd'}> {'由近到远'} </Option> <Option key={'lastupd'} value={'lastupd'}> {'由远到近'} </Option> </Select.OptGroup> </Select> </div> <div className="content-header-label"> {`共筛选出${totalNum}个模型`} </div> </Header> <Content className="model-square-content-main"> {modelList.map((item)=>{ return <div className="model-list-item" onClick={()=>{toDetails(item)}}> <div className="item-header"> <div className="item-header-left"> <img src={modelImg} /> </div> <div className="item-header-right"> <div className="item-header-right-top"> <div className="item-header-right-top-item label"> {item.modelLabel} </div> <div className="item-header-right-top-item name"> {item.modelName} </div> <div className="item-header-right-top-item tag"> <Tag color='orange'><IconShieldStarColor />{'已认证'}</Tag> </div> </div> <div className="item-header-right-bottom"> { item.tags.map((taglabel)=>{ return <Tag color='purple'>{taglabel}</Tag> }) } </div> </div> </div> <div className="item-content"> {`描述:${item.modelRemark}`} </div> <div className="item-footer"> <div className="footer-item"> <IconHardDiskColor /> <span> {item.modelOwnerName || item.modelOwner} </span> </div> <div className="footer-item-line"> </div> <div className="footer-item"> <IconRefreshColor /> <span> {item.lastupd} </span> </div> <div className="footer-item-line"> </div> <div className="footer-item"> <IconHeartColor /> <span> {item.favCnt} </span> </div> { item.routerId && (<Tag color="arcoblue" onClick={e => toExperience(e, item)}>体验</Tag>) } </div> </div> })} </Content> </Layout> </Content> </Layout> </div> </ModoTabs> } { isShowDetails && <div className="model-detail"> <div className="nav"> <Breadcrumb> <Breadcrumb.Item> <Button type="text" size="mini" className="back-btn" onClick={() => { setIsShowDetails(false) }}> 模型库 </Button> </Breadcrumb.Item> <Breadcrumb.Item> 模型详情 </Breadcrumb.Item> </Breadcrumb> </div> <Detail key={modelId + operType} modelId={modelId} isCanDeploy={true} operType={operType}/> </div> } </div> ); } export default ModelSquare; 解析这个代码 详细一点
07-25
<template> <view :style="colorStyle"> <view class="h-120 flex-between-center px-20"> <view class="h-72 bg--w111-f5f5f5 rd-36rpx px-32 flex-1 flex-y-center relative"> <text class="iconfont icon-ic_search text--w111-999"></text> <input type="text" confirm-type="search" placeholder="请输入要查询的内容" @confirm="inputConfirm" @input="setValue" class="fs-28 w-438 text--w111-333 pl-18 line1" v-model="searchValue" /> <text class="iconfont icon-ic_close1 fs-28 text--w111-999 z-10" v-show="searchValue" @tap="clearSearchVal"></text> </view> <view class="fs-28 text--w111-333 ml-32" @tap='searchBut'>搜索</view> </view> <view class="px-20" v-if="history.length"> <view class="flex-between-center mt-16 mb-24"> <view class="fs-28 lh-40rpx fw-500 text--w111-333">历史搜索</view> <text class="iconfont icon-ic_delete fs-28 text--w111-999" @tap="clear"></text> </view> <view class="flex flex-wrap"> <text class="flex-center h-56 line1 rd-28rpx bg--w111-f5f5f5 px-24 fs-24 text--w111-666 mr-24 mb-16" v-for="(item,index) in isShowMore ? history : history.slice(0,7)" :key="index" @tap='setHotSearchValue(item.keyword)' v-if="item.keyword">{{item.keyword}}</text> <view class="w-56 h-56 rd-28rpx bg--w111-f5f5f5 flex-center text--w111-666" v-if="history.length > 7" @tap="isShowMore = !isShowMore"> <text class="iconfont fs-24" :class="isShowMore ? 'icon-ic_uparrow' : 'icon-ic_downarrow'"></text> </view> </view> </view> <view class="px-20"> <view class="flex-between-center mt-40 mb-24"> <view class="fs-28 lh-40rpx fw-500 text--w111-333">热门搜索</view> <text class="iconfont icon-ic_Refresh fs-28 text--w111-999" :class="isSpin ? 'spin' : ''" @tap="refresh"></text> </view> <view class="flex flex-wrap"> <view class="flex-center search_item h-56 rd-28rpx px-24 fs-24 mr-24 mb-16" v-for="(item,index) in hotSearchList" :key="index" :style="{'color':item.color,'background-color':item.bg_color,border: item.border_color ? '1px solid ' + item.border_color : 'none'}" @tap='setHotSearchValue(item.name)'> <view class="flex-y-center"> <image v-if="item.icon" :src="item.icon" class="w-24 h-24 rd-4rpx mr-8"></image> <text>{{item.name}}</text> </view> </view> </view> </view> <view> <scroll-view scroll-x="true" class="white-nowrap vertical-middle w-730 mt-32 pl-20" show-scrollbar="false"> <view class="inline-block mr-20" v-if="salesRecommendList.length"> <view class="w-454 rd-24rpx gradient_bg pt-22 pb-8"> <view class="fs-28 font-red lh-40rpx fw-600 pl-24 mb-18 flex-y-center" @tap="goRank(1)"> <image src="@/static/img/sales_icon.png" class="w-40 h-40"></image> <text class="pl-8">销量</text> </view> <view class="mx-8 rd-24rpx bg--w111-fff h-748 p-20"> <view class="flex-y-center" v-if="salesRecommendList[0]" @tap="goDetail(salesRecommendList[0])"> <view class="relative w-108 h-108"> <image :src="salesRecommendList[0].image" class="w-108 h-108 rd-16rpx"></image> <view class="rank-count rank-count1 fs-24 text--w111-fff flex-center">1</view> </view> <view class="flex-1 h-108 flex-col flex-x-center ml-16"> <view class="w-260 fs-26 text--w111-333 lh-40rpx line1">{{salesRecommendList[0].store_name}}</view> <view class="w-260 fs-22 text--w111-999 lh-30rpx mt-8 line1">{{salesRecommendList[0].store_info}}</view> </view> </view> <view class="flex-y-center mt-16" v-if="salesRecommendList[1]" @tap="goDetail(salesRecommendList[1])"> <view class="relative w-108 h-108"> <image :src="salesRecommendList[1].image" class="w-108 h-108 rd-16rpx"></image> <view class="rank-count rank-count2 fs-24 text--w111-fff flex-center">2</view> </view> <view class="flex-1 h-108 flex-col flex-x-center ml-16"> <view class="flex-between-center"> <view class="w-260 fs-26 text--w111-333 lh-40rpx line1">{{salesRecommendList[1].store_name}}</view> </view> <view class="w-260 fs-22 text--w111-999 lh-30rpx mt-8 line1">{{salesRecommendList[1].store_info}}</view> </view> </view> <view class="flex-y-center mt-16 mb-34" v-if="salesRecommendList[2]" @tap="goDetail(salesRecommendList[2])"> <view class="relative w-108 h-108"> <image :src="salesRecommendList[2].image" class="w-108 h-108 rd-16rpx"></image> <view class="rank-count rank-count3 fs-24 text--w111-fff flex-center">3</view> </view> <view class="flex-1 h-108 flex-col flex-x-center ml-16"> <view class="flex-between-center"> <view class="w-260 fs-26 text--w111-333 lh-40rpx line1">{{salesRecommendList[2].store_name}}</view> </view> <view class="w-260 fs-22 text--w111-999 lh-30rpx mt-8 line1">{{salesRecommendList[2].store_info}}</view> </view> </view> <view class="flex-between-center scroll_cell" v-for="(item,index) in salesRecommendList.slice(3)" :key="index" @tap="goDetail(item)"> <view class="flex-y-center"> <text class="inline-block w-30 h-32 lh-32rpx text--w111-fff text-center fs-24 rank_4">{{index + 4}}</text> <text class="fs-26 text--w111-333 ml-20 w-360 line1"> <image v-if="item.delivery_type.indexOf('2') > -1" style="height:32.6rpx;width:116.08rpx;margin-right:10rpx;vertical-align:middle;" src="https://www.ytzhan.com/uploads/uniapp/2-glodzt.png"></image> <image v-if="item.delivery_type.indexOf('1') > -1" style="height:32.6rpx;width:116.08rpx;margin-right: 10rpx;vertical-align:middle;" src="https://www.ytzhan.com/uploads/uniapp/2-glodkd.png"></image><text style="vertical-align:middle;">{{item.store_name}}</text></text> </view> </view> </view> </view> </view> <view class="inline-block mr-20" v-if="scoreRecommendList.length"> <view class="w-454 rd-24rpx gradient_bg pt-22 pb-8"> <view class="fs-28 font-red lh-40rpx fw-600 pl-24 mb-18 flex-y-center" @tap="goRank(2)"> <image src="@/static/img/sales_icon.png" class="w-40 h-40"></image> <text class="pl-8">评分</text> </view> <view class="mx-8 rd-24rpx bg--w111-fff h-748 p-20"> <view class="flex-y-center" v-if="scoreRecommendList[0]" @tap="goDetail(scoreRecommendList[0])"> <view class="relative w-108 h-108"> <image :src="scoreRecommendList[0].image" class="w-108 h-108 rd-16rpx"></image> <view class="rank-count rank-count1 fs-24 text--w111-fff flex-center">1</view> </view> <view class="flex-1 h-108 flex-col flex-x-center ml-16"> <view class="flex-between-center"> <view class="w-260 fs-26 text--w111-333 lh-40rpx line1">{{scoreRecommendList[0].store_name}}</view> </view> <view class="w-260 fs-22 text--w111-999 lh-30rpx mt-8 line1">{{scoreRecommendList[0].store_info}}</view> </view> </view> <view class="flex-y-center mt-16" v-if="scoreRecommendList[1]" @tap="goDetail(scoreRecommendList[1])"> <view class="relative w-108 h-108"> <image :src="scoreRecommendList[1].image" class="w-108 h-108 rd-16rpx"></image> <view class="rank-count rank-count2 fs-24 text--w111-fff flex-center">2</view> </view> <view class="flex-1 h-108 flex-col flex-x-center ml-16"> <view class="flex-between-center"> <view class="w-260 fs-26 text--w111-333 lh-40rpx line1">{{scoreRecommendList[1].store_name}}</view> </view> <view class="w-260 fs-22 text--w111-999 lh-30rpx mt-8 line1">{{scoreRecommendList[1].store_info}}</view> </view> </view> <view class="flex-y-center mt-16 mb-34" v-if="scoreRecommendList[2]" @tap="goDetail(scoreRecommendList[2])"> <view class="relative w-108 h-108"> <image :src="scoreRecommendList[2].image" class="w-108 h-108 rd-16rpx"></image> <view class="rank-count rank-count3 fs-24 text--w111-fff flex-center">3</view> </view> <view class="flex-1 h-108 flex-col flex-x-center ml-16"> <view class="flex-between-center"> <view class="w-260 fs-26 text--w111-333 lh-40rpx line1">{{scoreRecommendList[2].store_name}}</view> </view> <view class="w-260 fs-22 text--w111-999 lh-30rpx mt-8 line1">{{scoreRecommendList[2].store_info}}</view> </view> </view> <view class="flex-between-center scroll_cell" v-for="(item,index) in scoreRecommendList.slice(3)" :key="index" @tap="goDetail(item)"> <view class="flex-y-center"> <text class="inline-block w-30 h-32 lh-32rpx text--w111-fff text-center fs-24 rank_4">{{index + 4}}</text> <text class="fs-26 text--w111-333 ml-20 w-360 line1"> <image v-if="item.delivery_type.indexOf('2') > -1" style="height:32.6rpx;width:116.08rpx;margin-right:10rpx;vertical-align:middle;" src="https://www.ytzhan.com/uploads/uniapp/2-glodzt.pngwww.ytzhan.com/uploads/uniapp/2-glodzt.png"></image> <image v-if="item.delivery_type.indexOf('1') > -1" style="height:32.6rpx;width:116.08rpx;margin-right: 10rpx;vertical-align:middle;" src="https://www.ytzhan.com/uploads/uniapp/2-glodzt.pngwww.ytzhan.com/uploads/uniapp/2-glodkd.png"></image>{{item.store_name}}</text> </view> </view> </view> </view> </view> <view class="inline-block mr-20" v-if="collectRecommendList.length"> <view class="w-454 rd-24rpx gradient_bg pt-22 pb-8"> <view class="fs-28 font-red lh-40rpx fw-600 pl-24 mb-18 flex-y-center" @tap="goRank(3)"> <image src="@/static/img/sales_icon.png" class="w-40 h-40"></image> <text class="pl-8">收藏</text> </view> <view class="mx-8 rd-24rpx bg--w111-fff h-748 p-20"> <view class="flex-y-center" v-if="collectRecommendList[0]" @tap="goDetail(collectRecommendList[0])"> <view class="relative w-108 h-108"> <image :src="collectRecommendList[0].image" class="w-108 h-108 rd-16rpx"></image> <view class="rank-count rank-count1 fs-24 text--w111-fff flex-center">1</view> </view> <view class="flex-1 h-108 flex-col flex-x-center ml-16"> <view class="flex-between-center"> <view class="w-260 fs-26 text--w111-333 lh-40rpx line1">{{collectRecommendList[0].store_name}}</view> </view> <view class="w-260 fs-22 text--w111-999 lh-30rpx mt-8 line1">{{collectRecommendList[0].store_info}}</view> </view> </view> <view class="flex-y-center mt-16" v-if="collectRecommendList[1]" @tap="goDetail(collectRecommendList[1])"> <view class="relative w-108 h-108"> <image :src="collectRecommendList[1].image" class="w-108 h-108 rd-16rpx"></image> <view class="rank-count rank-count2 fs-24 text--w111-fff flex-center">2</view> </view> <view class="flex-1 h-108 flex-col flex-x-center ml-16"> <view class="flex-between-center"> <view class="w-260 fs-26 text--w111-333 lh-40rpx line1">{{collectRecommendList[1].store_name}}</view> </view> <view class="w-260 fs-22 text--w111-999 lh-30rpx mt-8 line1">{{collectRecommendList[1].store_info}}</view> </view> </view> <view class="flex-y-center mt-16 mb-34" v-if="collectRecommendList[2]" @tap="goDetail(collectRecommendList[2])"> <view class="relative w-108 h-108"> <image :src="collectRecommendList[2].image" class="w-108 h-108 rd-16rpx"></image> <view class="rank-count rank-count3 fs-24 text--w111-fff flex-center">3</view> </view> <view class="flex-1 h-108 flex-col flex-x-center ml-16"> <view class="flex-between-center"> <view class="w-260 fs-26 text--w111-333 lh-40rpx line1">{{collectRecommendList[2].store_name}}</view> </view> <view class="w-260 fs-22 text--w111-999 lh-30rpx mt-8 line1">{{collectRecommendList[2].store_info}}</view> </view> </view> <view class="flex-between-center scroll_cell" v-for="(item,index) in collectRecommendList.slice(3)" :key="index" @tap="goDetail(item)"> <view class="flex-y-center"> <text class="inline-block w-30 h-32 lh-32rpx text--w111-fff text-center fs-24 rank_4">{{index + 4}}</text> <text class="fs-26 text--w111-333 ml-20 w-360 line1"> <image v-if="item.delivery_type.indexOf('2') > -1" style="height:32.6rpx;width:116.08rpx;margin-right:10rpx;vertical-align:middle;" src="https://www.ytzhan.com/uploads/uniapp/2-glodzt.pngwww.ytzhan.com/uploads/uniapp/2-glodzt.png"></image> <image v-if="item.delivery_type.indexOf('1') > -1" style="height:32.6rpx;width:116.08rpx;margin-right: 10rpx;vertical-align:middle;" src="https://www.ytzhan.com/uploads/uniapp/2-glodzt.pngwww.ytzhan.com/uploads/uniapp/2-glodkd.png"></image><text style="vertical-align:middle;">{{item.store_name}}</text></text> </view> </view> </view> </view> </view> </scroll-view> </view> <scroll-view scroll-y="true" class="fuzzy_modal" :style="{height:fuzzyHeight + 'px',top: 60 + 'px'}" v-if="newPartyList.length" @touchmove.stop.prevent="moveStop"> <view class="cell" v-for="(item,index) in newPartyList" :key="index" @tap="setCommentSearch(item.id)"> <view class="keyword line1" v-html="item.keyword"></view> </view> </scroll-view> </view> </template> <script> let sysHeight = uni.getSystemInfoSync().statusBarHeight; import home from '@/components/home/index.vue' import { getSearchKeyword, getSearchRecommendApi, getHotWordApi } from '@/api/store.js'; import { searchList, clearSearch } from '@/api/api.js'; import recommend from '@/components/recommend'; import colors from "@/mixins/color"; import { goShopDetail } from '@/libs/order.js'; import { HTTP_REQUEST_URL } from '@/config/app.js'; import { Debounce } from '@/utils/validate.js' export default { components: { recommend, home }, mixins: [colors], data() { return { hostProduct: [], searchValue: '', focus: true, bastList: [], hotSearchList: [], isSpin:false, first: 0, limit: 8, page: 1, loading: false, loadend: false, loadTitle: '加载更多', hotPage: 1, isScroll: true, history: [], imgHost: HTTP_REQUEST_URL, salesRecommendList:[], scoreRecommendList:[], collectRecommendList:[], sysHeight:sysHeight, newPartyList: [], //模糊搜索关键词列表 isShowMore: false }; }, computed: { fuzzyHeight() { let screenHeight = uni.getSystemInfoSync().screenHeight; return screenHeight - this.sysHeight - 56; } }, onLoad(e) { this.searchValue = e.searchVal || ''; this.getSearchHotKeywords(); this.getSearchRecommend(); setTimeout(()=>{ this.newPartySearch(); },1000) }, onShow: function(e) { uni.removeStorageSync('form_type_cart'); this.searchList(); }, methods: { refresh(){ this.isSpin = true; this.getSearchHotKeywords(); }, // 获取搜索热词 getSearchHotKeywords(){ getHotWordApi().then(res=>{ this.hotSearchList = res.data; setTimeout(_=>{ this.isSpin = false; },1000) }) }, searchList() { searchList({ page: 1, limit: 10 }).then(res => { this.history = res.data; }); }, clear() { let that = this; clearSearch().then(res => { uni.showToast({ title: res.msg, success() { that.history = []; } }); }); }, inputConfirm: function(event) { if (event.detail.value) { uni.hideKeyboard(); this.setHotSearchValue(event.detail.value); } }, setValue: Debounce(function(e){ this.newPartySearch(); }), newPartySearch: function() { getSearchKeyword({keyword:this.searchValue}).then(res => { this.newPartyList = res.data.list; this.newPartyList.map((item) => { this.$set(item,'keyword',this.brightKeyword(item.store_name,res.data.keyword)); }); }); }, brightKeyword(val,keyword) { if (val.indexOf(keyword) > -1) { val = `<p class="line1">${val}</p>` return val.replace(keyword, `<span style="color: #C9771E;">${keyword}</span>`); } else { return val; } }, setCommentSearch(id) { uni.navigateTo({ url:'/pages/goods/goods_list/index?productId=' + id }) }, setHotSearchValue: function(event) { this.$set(this, 'searchValue', event); this.focus = false; this.searchBut(); }, searchBut: function() { let that = this; that.focus = false; if (that.searchValue.length > 0) { this.newPartyList = []; uni.navigateTo({ url:'/pages/goods/goods_list/index?searchValue=' + that.searchValue }) } else { return this.$util.Tips({ title: '请输入要搜索的商品', icon: 'none', duration: 1000, mask: true, }); } }, getSearchRecommend(){ getSearchRecommendApi(1).then(res=>{ this.salesRecommendList = res.data; }) getSearchRecommendApi(2).then(res=>{ this.scoreRecommendList= res.data; }) getSearchRecommendApi(3).then(res=>{ this.collectRecommendList= res.data; }) }, // 去详情页 goDetail(item) { goShopDetail(item, this.uid).catch(res => { uni.navigateTo({ url: `/pages/goods_details/index?id=${item.id}` }); }); }, goRank(type){ uni.navigateTo({ url:`/pages/columnGoods/rank/index?type=${type}` }) }, clearSearchVal(){ this.searchValue = ''; this.newPartyList = []; } } } </script>排行榜有数据但是salesRecommendList、scoreRecommendList、collectRecommendList.length都为0且 即便res.data里有数据 打印出的length仍旧为0
06-24
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值