index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. <template>
  2. <view :style="{ minHeight: sys.windowHeight + 'px' }"
  3. :class="[$tm.vx.state().tmVuetify.black ? 'black' : ' ']">
  4. <tm-menubars title="搭配" :shadow="0" :showback="false"></tm-menubars>
  5. <view class="C1b1b1b pb-20">
  6. <tm-tabs align="left" class="qiehuan1" v-model="activeIndex" :list="list" range-key="title"></tm-tabs>
  7. </view>
  8. <!-- 天气 -->
  9. <scroll-view class="scroll-view_H" scroll-x="true">
  10. <view class="scroll-view-item_H" v-if="alltouList.length !=0">
  11. <image v-if="alltouList[0].data !=0" class="chuanda" :src="alltouList[0].data.makeAppointmentCollocation.image"></image>
  12. <view v-else class="chuanda">
  13. <view v-if="tianqiList" class="text-white text-size-lg">{{tianqiList.city}}市</view>
  14. <view v-if="tianqiList" class="text-size-lg mt-15 text-weight-b" style="color: #FFCC00;">{{tianqiList.temp}}°C</view>
  15. <view v-if="tianqiList" class="text-white text-size-lg mt-15">{{tianqiList.weather}}</view>
  16. <view v-if="tianqiList" class="text-gray text-size-lg mt-10">最低{{tianqiList.templow}}°c 最高{{tianqiList.temphigh}}°c</view>
  17. </view>
  18. <view class="mt-20 text-align-center" v-if="tianqiList">
  19. <image class="taiyang" src="/static/img/106.png" mode="widthFix"></image>
  20. <text class="text-size-s ml-15">{{tianqiList.templow}}°c~{{tianqiList.temphigh}}°c</text>
  21. <view class="text-size-s ml-15">{{tianqiList.date}} <text class="text-size-s ml-15">{{tianqiList.week}}</text></view>
  22. </view>
  23. <view v-if="alltouList[0]" class="bianji" @click="bianji(1,alltouList[0].data)">{{alltouList[0].data !=0?'更换穿搭':'添加穿搭'}}</view>
  24. </view>
  25. <view class="scroll-view-item_H" v-if="alltouList.length !=0">
  26. <image v-if="alltouList[1].data !=0" class="chuanda" :src="alltouList[1].data.makeAppointmentCollocation.image"></image>
  27. <view v-else class="chuanda">
  28. <view v-if="tianqiList" class="text-white text-size-lg">{{tianqiList.city}}市</view>
  29. <view v-if="tianqiList" class="text-size-lg mt-15 text-weight-b" style="color: #FFCC00;">{{tianqiList.daily[1].day.temphigh}}°C</view>
  30. <view v-if="tianqiList" class="text-white text-size-lg mt-15">{{tianqiList.daily[1].day.weather}}</view>
  31. <view v-if="tianqiList" class="text-gray text-size-lg mt-10">{{tianqiList.daily[1].day.winddirect}} {{tianqiList.daily[1].day.windpower}}°c</view>
  32. </view>
  33. <view class="mt-20 text-align-center" v-if="tianqiList">
  34. <image class="taiyang" src="/static/img/106.png" mode="widthFix"></image>
  35. <text class="text-size-s ml-15">最高温度{{tianqiList.daily[1].day.temphigh}}°C</text>
  36. <view class="text-size-s ml-15">{{tianqiList.daily[1].date}} <text class="text-size-s ml-15">{{tianqiList.daily[1].week}}</text></view>
  37. </view>
  38. <view v-if="alltouList[1]" class="bianji" @click="bianji(2,alltouList[1].data)">{{alltouList[1].data !=0?'更换穿搭':'添加穿搭'}}</view>
  39. </view>
  40. <!-- <view class="scroll-view-item_H">
  41. <view class="mt-20 text-align-center">
  42. <image class="taiyang" src="/static/img/106.png" mode="widthFix"></image>
  43. <text class="text-size-s ml-15">16°c~20°c</text>
  44. <text class="text-size-s ml-15">星期一</text>
  45. </view>
  46. <view class="bianji" @click="bianji(2)">添加穿搭</view>
  47. </view> -->
  48. <!-- <view class="scroll-view-item_H">
  49. <image class="chuanda" src="/static/img/107.png" mode="widthFix"></image>
  50. <view class="mt-20 text-align-center">
  51. <image class="taiyang" src="/static/img/106.png" mode="widthFix"></image>
  52. <text class="text-size-s ml-15">16°c~20°c</text>
  53. <text class="text-size-s ml-15">星期一</text>
  54. </view>
  55. <view class="bianji" @click="bianji()">编辑穿搭</view>
  56. </view> -->
  57. </scroll-view>
  58. <div class="zhuti">
  59. <!-- 衣橱 1-->
  60. <tm-sheet class="yichu" style="margin-bottom: 40px !important;">
  61. <tm-tabs @change="fenlei" class="C1b1b1b qiehuan" color="white" align="left" v-model="activeIndex1" :list="listfl" range-key="title"></tm-tabs>
  62. <view class="yiguicla black pa-6 ma-4 fl" v-for="(item,index) in quanbuList" @click="zidingyibianji(item)">
  63. <image :src="item.image" mode="widthFix"></image>
  64. <view class="text-size-m mt-20 mb-20 ml-10">{{item.title}}</view>
  65. </view>
  66. <view style="clear: both;"></view>
  67. <tm-empty v-if="quanbuList.length ==0" label="暂无数据" color="white" icon="icon-paperplane-fill"></tm-empty>
  68. <view v-if="total>quanbuList.length" style="clear: both;" class="more ma-40 pt-40" @click="gengmore()">
  69. <image src="/static/img/30.png" mode="widthFix"></image>
  70. <text class="text-size-s">下拉加载更多~</text>
  71. </view>
  72. </tm-sheet>
  73. <tm-button :round="24" class="sao" block @click="zidingyi()">自定义搭配</tm-button>
  74. </div>
  75. <!-- 弹出层消息 -->
  76. <tm-message ref="toast"></tm-message>
  77. </view>
  78. </template>
  79. <script>
  80. import{myRequest} from '@/api/request.js'
  81. import qqmapsdk from '../../js_sdk/qqmap-wx-jssdk.js'
  82. const QQMapWX = new qqmapsdk({
  83. key: 'KNABZ-OAVCJ-O5IFJ-KBNST-SVIIZ-2EB3G'
  84. });
  85. export default {
  86. data() {
  87. return {
  88. list:[ '预约穿搭'],
  89. activeIndex:0,
  90. activeIndex1:0,
  91. quanbuList:[],
  92. chooseindex:-1,
  93. listfl:[],
  94. listflall:[],
  95. alltouList:[],
  96. tianqiList:[],
  97. page:1,
  98. total:0,
  99. pagesize:10,
  100. city:'南京'
  101. };
  102. },
  103. onLoad(e) {
  104. },
  105. onShow(){
  106. this.page=1;
  107. this.getFl();
  108. this.touFun();
  109. this.getCity()
  110. },
  111. created() {
  112. this.sys = uni.getSystemInfoSync();
  113. this.gettianqi();
  114. },
  115. methods: {
  116. getCity(){
  117. var that=this;
  118. uni.getLocation({
  119. type: 'wgs84',
  120. geocode: true,
  121. success: (res) => {
  122. this.latitude = res.latitude;
  123. this.longitude = res.longitude;
  124. },
  125. fail: () => {
  126. },
  127. complete: () => {
  128. // 解析地址
  129. QQMapWX.reverseGeocoder({
  130. location: {
  131. latitude: this.latitude,
  132. longitude: this.longitude
  133. },
  134. success: function(res) {
  135. // 省
  136. let province = res.result.ad_info.province;
  137. // 市
  138. let city = res.result.ad_info.city;
  139. //区
  140. let district=res.result.ad_info.district;
  141. that.city=city;
  142. },
  143. fail: function(res) {
  144. // uni.showToast({
  145. // title: '定位失败',
  146. // duration: 2000,
  147. // icon: "none"
  148. // })
  149. },
  150. complete: function(res) {
  151. }
  152. })
  153. }
  154. })
  155. },
  156. shuaxin(){
  157. this.activeIndex1=0;
  158. this.page=1;
  159. this.getFl();
  160. this.touFun();
  161. },
  162. fenlei(e){
  163. this.page=1;
  164. this.getKxuan()
  165. },
  166. touFun(){
  167. var that=this;
  168. // 11
  169. myRequest({
  170. url: "/api/Collocation/selectStyle",
  171. method:'post',
  172. data:{}
  173. }).then(res => {
  174. if (res.data.code == 200) {
  175. var dataList=res.data.data;
  176. if(dataList.length==0){
  177. that.alltouList[0]={data:0}
  178. that.alltouList[1]={data:0}
  179. }else if(dataList.length==1){
  180. for(let i=0;i<dataList.length;i++){
  181. if(dataList[i].type==1){
  182. that.alltouList[0]={data:dataList[i]}
  183. }else{
  184. that.alltouList[0]={data:0}
  185. }
  186. if(dataList[i].type==2){
  187. that.alltouList[1]={data:dataList[i]}
  188. }else{
  189. that.alltouList[1]={data:0}
  190. }
  191. }
  192. }else{
  193. for(let i=0;i<dataList.length;i++){
  194. if(dataList[i].type==1){
  195. that.alltouList[0]={data:dataList[i]}
  196. }
  197. if(dataList[i].type==2){
  198. that.alltouList[1]={data:dataList[i]}
  199. }
  200. }
  201. }
  202. }else{
  203. that.alltouList[0]={data:0}
  204. that.alltouList[1]={data:0}
  205. }
  206. })
  207. },
  208. getFl(){
  209. var that=this;
  210. myRequest({
  211. url: "/api/Category/getCollocationClassList",
  212. method:'post',
  213. data:{}
  214. }).then(res => {
  215. if (res.data.code == 200) {
  216. if(res.data.data.length != 0){
  217. // that.listfl=['全部'];
  218. that.listfl=[];
  219. for(let i=0;i<res.data.data.length;i++){
  220. that.listfl.push(res.data.data[i].category_name)
  221. }
  222. that.listflall=res.data.data;
  223. that.getKxuan();
  224. }
  225. }else{
  226. that.listfl=[];
  227. }
  228. })
  229. },
  230. gengmore() {
  231. this.page=this.page+1;
  232. this.getKxuan();
  233. },
  234. getKxuan(){
  235. var that=this;
  236. myRequest({
  237. url: "/api/Collocation/getCollocationList",
  238. method:'post',
  239. data:{category_id:that.listflall[that.activeIndex1].id,page:that.page,pagesize:that.pagesize}
  240. }).then(res => {
  241. if (res.data.code == 200) {
  242. if(res.data.data.length != 0){
  243. if(this.page==1){
  244. that.quanbuList=res.data.data.data;
  245. }else{
  246. that.quanbuList=that.quanbuList.concat(res.data.data.data);
  247. }
  248. that.total=res.data.data.total;
  249. }else{
  250. that.quanbuList=[];
  251. that.total=0;
  252. }
  253. }else{
  254. that.quanbuList=[];
  255. that.total=0;
  256. }
  257. })
  258. },
  259. gettianqi(){
  260. var that=this;
  261. // uni.getLocation({
  262. // type: 'wgs84',
  263. // geocode:true,//设置该参数为true可直接获取经纬度及城市信息
  264. // success: function (res) {
  265. // // that.addrDel = res;
  266. // },
  267. // fail: function () {
  268. // uni.showToast({
  269. // title: '获取地址失败,将导致部分功能不可用',
  270. // icon:'none'
  271. // });
  272. // }
  273. // });
  274. uni.request({
  275. url: "https://jisutqybmf.market.alicloudapi.com/weather/query",
  276. method: "get",
  277. header: {
  278. 'Authorization':'APPCODE b838ad36bbd741ad97bbe22e50be1847'
  279. },
  280. data:{
  281. city:that.city
  282. },
  283. dataType:'json',
  284. success : function(data) {
  285. that.tianqiList=data.data.result;
  286. },
  287. error : function(e) {
  288. alert("网络异常,请重试");
  289. }
  290. });
  291. },
  292. bianji(type,data){
  293. if(data.makeAppointmentCollocation){
  294. uni.navigateTo({
  295. url: "/pages/bianjigh/index?type="+type+'&id='+data.id+"&old="+data.collocation_id,
  296. })
  297. }else{
  298. uni.navigateTo({
  299. url: "/pages/bianjigh/index?type="+type,
  300. })
  301. }
  302. },
  303. zidingyibianji(item){
  304. if(item.type==2){
  305. // 衣橱
  306. uni.navigateTo({
  307. url: "/pages/baocun/index?id="+item.id+"&type=2",
  308. })
  309. }else{
  310. // 大数据推荐1
  311. uni.navigateTo({
  312. url: "/pages/zidingyikan/index?id="+item.id+"&type=2",
  313. })
  314. }
  315. // uni.navigateTo({
  316. // url: "/pages/zidingyi/index?type=1",
  317. // })
  318. },
  319. dapei(){
  320. uni.navigateTo({
  321. url: "/pages/dapeizidingyi/index?type=1",
  322. })
  323. },
  324. zidingyi(){
  325. uni.navigateTo({
  326. url: "/pages/changan/index",
  327. })
  328. }
  329. },
  330. }
  331. </script>
  332. <style lang="scss">
  333. /deep/ .tm-menubars .body{
  334. background-color: #1b1b1b !important;
  335. }
  336. /deep/ .qiehuan1 .text-primary{color: white !important;}
  337. .chuanda{width: 100%;height: 144px;}
  338. .taiyang{width: 25px;}
  339. .bianji{border: 1px solid #303440;width: 80px;height: 30px;background: #303440;font-size: 15px;
  340. text-align: center;line-height: 30px;border-radius: 5px;margin: 0 auto;margin-top: 10px;border:1px solid white;}
  341. .scroll-view_H {
  342. white-space: nowrap;
  343. width: 100%;
  344. background: #1B1B1B;
  345. padding-bottom: 15px;
  346. }
  347. .scroll-view-item {
  348. height: 300rpx;
  349. text-align: center;
  350. font-size: 36rpx;
  351. }
  352. .scroll-view-item_H {
  353. display: inline-block;
  354. width: 150px;
  355. text-align: center;
  356. font-size: 36rpx;
  357. margin-left: 10px;
  358. background: #0D0D0D;
  359. padding: 6px;
  360. border-radius: 10px;
  361. }
  362. .yichu{margin:0 !important;padding: 4px !important;margin-top: 10px !important;}
  363. /deep/ .qiehuan .text-white{
  364. font-size: 14px;
  365. background: #303440;
  366. height: 28px;
  367. vertical-align: middle;
  368. line-height: 28px;
  369. border-radius: 20px;
  370. padding-left: 14px;
  371. padding-right: 14px;
  372. margin-top: 17%;
  373. }
  374. /deep/ .qiehuan .tm-tabs-con-item-border{display: none;}
  375. .yiguicla image{width: 95%;display: block;margin: 0 auto;margin-top: 5px;}
  376. .yiguicla{width: 47%;border-radius: 10px;}
  377. .more{text-align: center;}
  378. .more image{margin-right: 10px;vertical-align: middle;width: 30px;}
  379. .fudong{position:fixed;right:10px;bottom:150px;background: #303030;width: 130px;height: 60px;
  380. border-radius: 30px 0px 0px 30px;font-size: 14px;text-align: center;}
  381. .sao{width: 60%;display: block;margin: 0 auto;margin-bottom: 60px;}
  382. /deep/ .scroll-view_H{height:260px !important;}
  383. </style>