index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  1. <template>
  2. <view class="">
  3. <view class="drawer">
  4. <view class="topContentV">
  5. <mynavbar class="mynavbarV" :title="Btitle" titledetl="" :interestBT="0" :mycartBT="1" v-on:Enavbarsel="navbarsel"></mynavbar>
  6. <view class="toptalbar">
  7. <view v-for="(item,index) in tableList">
  8. <text :class="toptableindex==index?'tableLab tableselect':'tableLab'" @click="tableselct(item.value,index)">{{item.text}}</text>
  9. </view>
  10. </view>
  11. </view>
  12. </view>
  13. <view v-if="isLogin" class="content4 listView">
  14. <foodlistItem :orderlist="orderlist" v-on:ERefresh="Refresh"></foodlistItem>
  15. </view>
  16. <view v-if="!isLogin" class="contentColumnC" style="margin-top: 260rpx;">
  17. <image class="weidenglu" src="/static/msdshj/qishouIM.png" mode="aspectFit"></image>
  18. <text class="xuacyuA"> </text>
  19. <view class="contentColumnC" style="width: 100%;">
  20. <view class="texing">
  21. <view class="contentInRowL" style="align-items: center;">
  22. <uni-icons custom-prefix="custom-icon" color="#386EF5" type="checkbox" size="22"></uni-icons>
  23. <text class="textfontB3">{{$t('user.hailiangdd')}}</text>
  24. </view>
  25. <view class="contentInRowL" style="align-items: center;margin-top: 20rpx;">
  26. <uni-icons custom-prefix="custom-icon" color="#386EF5" type="checkbox" size="22"></uni-icons>
  27. <text class="textfontB3">{{$t('user.caozuojid')}}</text>
  28. </view>
  29. <view class="contentInRowL" style="align-items: center;margin-top: 20rpx;">
  30. <uni-icons custom-prefix="custom-icon" color="#386EF5" type="checkbox" size="22"></uni-icons>
  31. <text class="textfontB3">{{$t('user.shirkek')}}</text>
  32. </view>
  33. </view>
  34. </view>
  35. <view class="contentColumnC texing" style="width: 100%;">
  36. <text class="textfontB3">美食達</text>
  37. <text class="textfontB3">{{$t('user.chengyaojm')}}</text>
  38. </view>
  39. </view>
  40. <view v-if="isLogin">
  41. <view v-if="orderlist.length==0&&isLogin" class="contentColumnC">
  42. <image class="weishimingImage" src="/static/images/dingdan1@3x.png" mode="widthFix"></image>
  43. <text class="meiyouText">{{$t('order.dangqmydd')}}</text>
  44. </view>
  45. </view>
  46. <view style="height: 20rpx;"></view>
  47. <popViewGG :tips="$t('user.xiazaijindu')" :show="show" :maskClosable="false" :isCancel="false">
  48. <view class="words">
  49. <text>{{$t('user.xiazaizhong')}} {{percentVal}}%</text>
  50. </view>
  51. </popViewGG>
  52. <uni-popup style="z-index: 999;" ref="popYsxy" type="center" :isMaskClick="false" :safeArea="true">
  53. <ysxyView v-on:EagrResult="agrResult"></ysxyView>
  54. </uni-popup>
  55. </view>
  56. </template>
  57. <script>
  58. import mynavbar from "@/pages/component/mynavbar/mynavbar.vue";
  59. import api from "@/pages/api/api.js"
  60. export default {
  61. components:{
  62. mynavbar
  63. },
  64. data() {
  65. return {
  66. formData: {
  67. status: 'loading', // 加载状态
  68. },
  69. tipShow: false ,// 是否显示顶部提示框
  70. Btitle:"",
  71. isLogin:false,
  72. token:'',
  73. mendid:'',
  74. mendianList:[],
  75. versionMSG:[],
  76. appVersionCode:0,
  77. updateUrl:'',
  78. tishigx:true,
  79. show:false,
  80. percentVal:'',
  81. orderlist:[],
  82. tableList:[],
  83. toptableindex:0,
  84. state:'z01',
  85. page:1,
  86. timer:null
  87. }
  88. },
  89. onLoad() {
  90. var info = uni.getSystemInfoSync();
  91. //console.log(info);
  92. this.appVersionCode=info.appVersionCode;
  93. },
  94. onReady() {
  95. var yszche=uni.getStorageSync('yszche');
  96. if(1!=yszche){
  97. this.$refs.popYsxy.open('center');
  98. uni.hideTabBar();
  99. }
  100. },
  101. onShow() {
  102. this.tableList=[
  103. { value: 1, text: this.$t('order.daishouli') },
  104. { value: 2, text: this.$t('order.daichuchan') },
  105. { value: 5, text: this.$t('order.yichuchan') },
  106. { value: 6, text: this.$t('order.shouhou') },
  107. ];
  108. var yszche=uni.getStorageSync('yszche');
  109. if(1!=yszche){
  110. return;
  111. }
  112. this.getVersion();
  113. this.token = uni.getStorageSync("token");
  114. console.log('------11this.token',this.token)
  115. if(this.token == '' || this.token == undefined || this.token == null){
  116. // uni.navigateTo({
  117. // url:'/pages/UserCenter/LoginView'
  118. // })
  119. this.isLogin=false;
  120. return;
  121. }
  122. else{
  123. this.isLogin=true;
  124. this.chongxindenglu();
  125. }
  126. this.mendid = uni.getStorageSync("mendid");
  127. this.getMymendianlist();
  128. if(this.tishigx){
  129. this.tishigx=false;
  130. }
  131. else{
  132. this.getstoreorderlist(1,this.state);
  133. }
  134. this.timerAct();
  135. },
  136. onHide() {
  137. this.clearTimer();
  138. },
  139. methods: {
  140. getMymendianlist(){
  141. //this.formData.status = 'more'
  142. this.tipShow = true
  143. api('getMymendianlist',{},
  144. r=>{
  145. this.mendianList=r.data.data;
  146. console.log(this.mendianList);
  147. if(this.mendid==''||undefined==this.mendid||null==this.mendid){
  148. if(this.mendianList&&this.mendianList.length>0){
  149. this.mendid=this.mendianList[0].id;
  150. this.Btitle=this.mendianList[0].posName;
  151. }
  152. }
  153. else{
  154. this.chonsemendian();
  155. }
  156. this.getstoreorderlist(1,this.state);
  157. },failc=>{
  158. //console.log('getadvertis----',failc)
  159. uni.stopPullDownRefresh()
  160. this.tipShow = false
  161. });
  162. },
  163. chonsemendian(){
  164. for(var i=0;i<this.mendianList.length;i++){
  165. var mend = this.mendianList[i];
  166. if(mend.id==this.mendid){
  167. this.Btitle=mend.posName;
  168. return;
  169. }
  170. }
  171. this.mendid=this.mendianList[0].id;
  172. this.Btitle=this.mendianList[0].posName;
  173. },
  174. tableselct(id,index){
  175. if(!this.isLogin){
  176. uni.navigateTo({
  177. url:'/pages/UserCenter/LoginView'
  178. })
  179. return;
  180. }
  181. console.log('tableselct',index)
  182. this.toptableindex=index;
  183. this.state = id;
  184. this.page = 1;
  185. if(id==1){
  186. this.state='z01';
  187. }
  188. if(id==2){
  189. this.state='z23';
  190. }
  191. if(id==6){
  192. this.state='z678911';
  193. }
  194. this.getstoreorderlist(1,this.state);
  195. },
  196. timerAct(){
  197. this.clearTimer();
  198. var that = this;
  199. that.timer = setInterval(() => {
  200. //console.log('setInterval',that.toptableindex)
  201. if(that.toptableindex==0||that.toptableindex==1){
  202. that.Refresh();
  203. }
  204. }, 20000);
  205. },
  206. clearTimer() {
  207. // clearTime
  208. if (this.timer) {
  209. clearInterval(this.timer);
  210. this.timer = null;
  211. }
  212. },
  213. Refresh(){
  214. this.getstoreorderlist(1,this.state);
  215. },
  216. navbarsel(item){
  217. console.log(item);
  218. if(item==1){
  219. uni.switchTab({
  220. url: '/pages/UserCenter/UserCenter'
  221. });
  222. return
  223. }
  224. if(item==2){
  225. if(!this.isLogin){
  226. uni.navigateTo({
  227. url:'/pages/UserCenter/LoginView'
  228. })
  229. return;
  230. }
  231. uni.navigateTo({
  232. url:'/pages/UserCenter/mendian/xuanzemendian'
  233. })
  234. return
  235. }
  236. },
  237. getstoreorderlist(page,state){
  238. console.log('-----------',state,this.mendid)
  239. if(state<0){
  240. state = '';
  241. }
  242. if(state=='z23'){
  243. this.getdaichucan(page,state,0);
  244. return;
  245. }
  246. if(state==5){
  247. this.getdaichucan(page,'',1);
  248. return;
  249. }
  250. this.formData.status = 'more'
  251. this.tipShow = true
  252. uni.showLoading({
  253. title:'Loading...',
  254. mask:true
  255. })
  256. console.log(state,this.mendid)
  257. api('getstoreorderlist',{
  258. page:page,
  259. size:10,
  260. state:state,
  261. mdId:this.mendid
  262. },
  263. r=>{
  264. console.log(r);
  265. uni.hideLoading();
  266. if(page!=1){
  267. if(r.data.data){
  268. if(r.data.data.length>0){
  269. var temp = this.orderlist;
  270. for(var i=0;i<r.data.data.length;i++){
  271. temp.push(r.data.data[i]);
  272. }
  273. // this.orderlist=[];
  274. // this.orderlist.push(temp);
  275. this.orderlist=temp;
  276. }
  277. else{
  278. this.status = 'noMore';
  279. }
  280. }
  281. else{
  282. this.status = 'noMore';
  283. }
  284. }
  285. else{
  286. // this.orderlist=[];
  287. // this.orderlist.push(r.data.data);
  288. this.orderlist=r.data.data;
  289. this.status = 'more';
  290. }
  291. uni.stopPullDownRefresh();
  292. this.tipShow = false;
  293. },failc=>{
  294. uni.hideLoading();
  295. uni.stopPullDownRefresh()
  296. this.tipShow = false
  297. });
  298. },
  299. getdaichucan(page,state,diningStatus){
  300. uni.showLoading({
  301. title:'Loading...',
  302. mask:true
  303. })
  304. this.formData.status = 'more'
  305. this.tipShow = true;
  306. api('getstoreorderlist',{
  307. page:page,
  308. size:10,
  309. state:state,//空或z23
  310. diningStatus:diningStatus,//0h或1
  311. mdId:this.mendid
  312. },
  313. r=>{
  314. console.log(r);
  315. uni.hideLoading();
  316. if(page!=1){
  317. if(r.data.data){
  318. if(r.data.data.length>0){
  319. var temp = this.orderlist;
  320. for(var i=0;i<r.data.data.length;i++){
  321. temp.push(r.data.data[i]);
  322. }
  323. // this.orderlist=[];
  324. // this.orderlist.push(temp);
  325. this.orderlist=temp;
  326. }
  327. else{
  328. this.status = 'noMore';
  329. }
  330. }
  331. else{
  332. this.status = 'noMore';
  333. }
  334. }
  335. else{
  336. // this.orderlist=[];
  337. // this.orderlist.push(r.data.data);
  338. this.orderlist=r.data.data;
  339. this.status = 'more';
  340. }
  341. uni.stopPullDownRefresh();
  342. this.tipShow = false;
  343. },
  344. failc=>{
  345. uni.hideLoading();
  346. uni.stopPullDownRefresh()
  347. this.tipShow = false
  348. });
  349. },
  350. /**
  351. * 下拉刷新回调函数
  352. */
  353. onPullDownRefresh() {
  354. this.getstoreorderlist(1,this.state);
  355. this.page=1;
  356. },
  357. /**
  358. * 上拉加载回调函数
  359. */
  360. onReachBottom() {
  361. console.log('onReachBottom')
  362. this.page=this.page+1;
  363. this.getstoreorderlist(this.page,this.state);
  364. },
  365. chongxindenglu(){
  366. var that =this;
  367. try {//读取
  368. that.token = uni.getStorageSync("token");
  369. getApp().globalData.token = that.token;
  370. if(this.token == '' || this.token == undefined || this.token == null){
  371. // uni.navigateTo({
  372. // url:'/pages/UserCenter/LoginView'
  373. // })
  374. return;
  375. }
  376. else{
  377. this.gengxintoken(that.token);
  378. return;
  379. }
  380. } catch(e){//错误
  381. return;
  382. }
  383. },
  384. gengxintoken(token){
  385. api('refreshToken',{
  386. },
  387. r=>{
  388. console.log('gengxintoken',r)
  389. if(r.data.code==200){
  390. this.isLogin=true;
  391. uni.setStorageSync("token",r.data.data);
  392. getApp().globalData.token = r.data.data;
  393. this.getUserMsg(r.data.data);
  394. }
  395. else{
  396. uni.navigateTo({
  397. url:'/pages/UserCenter/LoginView'
  398. })
  399. }
  400. },failc=>{
  401. uni.hideLoading();
  402. uni.stopPullDownRefresh()
  403. this.tipShow = false
  404. });
  405. },
  406. getUserMsg(token){
  407. //console.log('getUserMsg')
  408. api('getUserMsg',{
  409. },
  410. r=>{
  411. console.log(r.data)
  412. if(r.data.code==200){
  413. let items = JSON.stringify(r.data.data);
  414. uni.setStorageSync('userInfo',items);
  415. this.getCID();
  416. }
  417. },failc=>{
  418. console.log(failc)
  419. });
  420. },
  421. getCID(){
  422. var cid = uni.getStorageSync("cid");
  423. if(cid==''||cid==null||cid==undefined){
  424. var that = this;
  425. uni.getPushClientId({
  426. success: (res) => {
  427. //console.log('客户端推送标识:',res.cid)
  428. uni.setStorageSync("cid",res.cid);
  429. var usdata = {
  430. "cid":res.cid,
  431. };
  432. that.updataUserMsg(usdata);
  433. },
  434. fail(err) {
  435. console.log(err)
  436. }
  437. });
  438. }
  439. else{
  440. var usdata = {
  441. "cid":cid,
  442. };
  443. this.updataUserMsg(usdata)
  444. }
  445. },
  446. updataUserMsg(data){
  447. api('updataUserMsg',data,
  448. res=>{
  449. console.log(res)
  450. uni.navigateBack({
  451. delta:1,//返回层数,2则上上页
  452. })
  453. },failc=>{
  454. //console.log('getadvertis----',failc)
  455. });
  456. },
  457. agrResult(state){//隐私协议
  458. console.log(state);
  459. if(state==0){
  460. if (plus.os.name.toLowerCase() === 'android') {
  461. console.log('ios');
  462. plus.runtime.quit();
  463. }
  464. else{
  465. console.log('ios');
  466. plus.ios.import("UIApplication").sharedApplication().performSelector("exit")
  467. }
  468. }
  469. if(state==1){
  470. uni.showTabBar();
  471. this.$refs.popYsxy.close();
  472. uni.setStorageSync('yszche',1);
  473. this.chongxindenglu();
  474. }
  475. if(state==2){
  476. uni.navigateTo({
  477. url:'/pages/index/mindex/yinszhengc'
  478. })
  479. }
  480. },
  481. //自动更新
  482. getVersion(){
  483. return;
  484. var info = uni.getSystemInfoSync();
  485. console.log(info);
  486. if(info.platform.toLowerCase() != 'android'){
  487. return;
  488. }
  489. var appVersionCode = info.appVersionCode;
  490. var that = this;
  491. api('getversion',{
  492. platform:'0',
  493. name:'CTE.cooperate'
  494. },
  495. res=>{
  496. console.log(res);
  497. if(res.data.data){
  498. var versionMSG=res.data.data;
  499. if(appVersionCode<versionMSG.version){
  500. uni.showModal({
  501. cancelText: that.$t('order.quxiao'), // 取消按钮的文字
  502. confirmText: that.$t('index.shengji'), // 确认按钮的文字
  503. title: that.$t('api.message'),
  504. content: that.$t('index.yiyouxinban'),
  505. success: function (res) {
  506. if (res.confirm) { //这里是点击了确定以后
  507. var updateUrl='http://backend.cityexpress168.com.vn/androidApk/CTE.cooperate.apk';
  508. that.gengxinApp(updateUrl);
  509. } else { //这里是点击了取消以后
  510. console.log('用户点击取消')
  511. }
  512. }
  513. })
  514. }
  515. }
  516. },failc=>{
  517. //console.log('getadvertis----',failc)
  518. });
  519. },
  520. gengxinApp(url){
  521. console.log(url);
  522. var that = this;
  523. var dtask = plus.downloader.createDownload(
  524. url,
  525. {
  526. method: "GET"
  527. }, (d, status) => {
  528. console.log(status,d);
  529. if (status == 200) {
  530. plus.runtime.install(d.filename)
  531. } else {
  532. plus.nativeUI.alert('fail!' + status)
  533. }
  534. });
  535. dtask.start();
  536. var prg = 0;//进度数字化
  537. var show= plus.nativeUI.showWaiting("Loading...");
  538. var percentVal;
  539. dtask.addEventListener('statechanged',function(task,status){
  540. //console.log(task);
  541. switch(task.state){//根据下载状态调整其显示内容
  542. case 1:
  543. percentVal = "Loading……";
  544. show.setTitle("Loading……");
  545. break;
  546. case 2:
  547. percentVal = "Connected";
  548. show.setTitle("Connected");
  549. break;
  550. case 3:
  551. percentVal = parseInt((parseFloat(task.downloadedSize) / parseFloat(task.totalSize)) * 100);
  552. show.setTitle("Loading:" + percentVal + "%");
  553. break;
  554. case 4:
  555. plus.nativeUI.closeWaiting();
  556. break;
  557. }
  558. });
  559. },
  560. }
  561. }
  562. </script>
  563. <style scoped lang="scss">
  564. .contentbg{
  565. margin-top: 140rpx;
  566. }
  567. .mynavbarV{
  568. z-index: 999;
  569. background-color: #40AE36;
  570. }
  571. .topContentV{
  572. position: fixed;
  573. padding-top: 40rpx;
  574. width: 750upx;
  575. left: 0;
  576. right: 0;
  577. top: 0;
  578. z-index: 999;
  579. background-color: #40AE36;
  580. }
  581. .toptalbar{
  582. display: flex;
  583. flex-direction: row;
  584. justify-content:space-between;
  585. align-items: center;
  586. background-color: #40AE36;
  587. padding-top: 10rpx;
  588. height: 90rpx;
  589. margin-left: 6rpx;
  590. margin-right: 6rpx;
  591. }
  592. .tableLab{
  593. width: 24%;
  594. text-align: center;
  595. margin-left: 14rpx;
  596. height: 90rpx;
  597. line-height: 28rpx;
  598. font-size: 24rpx;
  599. color: white;
  600. }
  601. .tableselect{
  602. border-bottom-width: 6rpx;
  603. border-bottom-style:solid;
  604. border-bottom-color:white;
  605. color: white;
  606. font-size: 28rpx;
  607. }
  608. .weidenglu{
  609. width: 600rpx;
  610. height: 600rpx;
  611. }
  612. .xuacyuA{
  613. font-size: 26rpx;
  614. font-family: 'zrht';
  615. font-weight: bold;
  616. letter-spacing: 4rpx;
  617. margin-left: 160rpx;
  618. margin-top: 80rpx;
  619. }
  620. .texing{
  621. font-size: 24rpx;
  622. font-weight: bold;
  623. font-family: 'zrht';
  624. //width: 600rpx;
  625. letter-spacing: 2rpx;
  626. margin-top: 40rpx;
  627. color: #40AE36;
  628. align-items: center;
  629. justify-content: flex-start;
  630. }
  631. //抽屉实现
  632. .drawer{
  633. width: 100%;
  634. padding-left: 0;
  635. position: absolute;
  636. background-color: white;
  637. }
  638. .words{
  639. width: 100%;
  640. text-align: center;
  641. font-size: 30rpx;
  642. height: 80rpx;
  643. line-height: 80rpx;
  644. }
  645. .listView{
  646. margin-top: 290rpx;
  647. margin-bottom: 20rpx;
  648. }
  649. .weishimingImage{
  650. width: 30%;
  651. margin-top: 340rpx;
  652. }
  653. .meiyouText{
  654. font-size: 28rpx;
  655. font-weight: bold;
  656. color: black;
  657. }
  658. </style>