shangjiaView.vue 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700
  1. <template>
  2. <view style="background-color: whitesmoke;" @touchstart="rightF" @touchend="leftF">
  3. <customNav :shownav="true" :title="posName" titledetl=""></customNav>
  4. <view style="width: 100%;height: 80rpx;background-color: #00A6FF;"></view>
  5. <view class="nodetail">
  6. <view class="contentInRowS" style="width: 100%;">
  7. <netImage style="margin-left: 12rpx;margin-top: -20rpx;" width="160" height="160" bradius="80"
  8. :mysrc="mendianMs.logo" mymode="scaleToFill"></netImage>
  9. <view class="contentColumn" style="width: 500rpx;margin-right: 20rpx;">
  10. <text class="dianpuming">{{mendianMs.posName}}</text>
  11. <text class="peisongsuoming">{{$t('index.manX')}} {{$formPr(mendianMs.posPrice)}}
  12. {{$t('locale.huobidw')}}</text>
  13. <view class="contentInRowS">
  14. <view class="contentColumnC" style="width: 24%; visibility: hidden;">
  15. <image class="actimge" :src="shouchangIcon" mode="aspectFit" @click="shouchang"></image>
  16. <text class="textfontS3">{{$t('index.shouchang')}}</text>
  17. </view>
  18. <view class="contentColumnC" style="width: 24%;">
  19. <image class="actimge" src="/static/images/daipinglun@3x.png" mode="aspectFit"
  20. @click="pinglunList"></image>
  21. <text class="textfontS3">{{$t('index.pinglun')}}</text>
  22. </view>
  23. <view class="contentColumnC" style="width: 24%;">
  24. <image class="actimge" src="/static/images/gengduozx.png" mode="aspectFit"
  25. @click="gengduozx"></image>
  26. <text class="textfontS3">{{$t('index.mendian')}}</text>
  27. </view>
  28. <view class="contentColumnC" style="width: 24%;">
  29. <image class="actimge" src="/static/images/lianxikf.png" mode="aspectFit"
  30. @click="callPhone"></image>
  31. <text class="textfontS3">{{$t('mend.kefudianhua')}}</text>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. <view v-if="mendianMs.state==1" class="contentInRowR">
  37. <text
  38. style="margin-top: 10rpx;color: darkgreen;font-size: 28rpx;padding-right: 40rpx;">{{$t('mend.statedy')}}</text>
  39. </view>
  40. <view style="height: 20rpx;"></view>
  41. </view>
  42. <view v-if="cuxiaoImge.length==0">
  43. <netImage style="margin-top:20rpx;margin-left: 25rpx;" width="700" height="400" bradius="6"
  44. :mysrc="mendianMs.image" mymode="scaleToFill"></netImage>
  45. </view>
  46. <view v-if="cuxiaoImge.length>0"><!-- 促销活动 -->
  47. <swiperImgs style="margin-top: 20rpx;" width="750" height="400" :imageList="cuxiaoImge"></swiperImgs>
  48. </view>
  49. <view style="margin-top: 40rpx;">
  50. <view :class="[(isFixedTop[0]) ?cssName:'']" id="box" class="box">
  51. <view class="contentInRowL"
  52. style="width: 90%;margin-left: 5%;margin-bottom: 20rpx;align-items: center;">
  53. <view>
  54. <text class="fenleiTitle" @click="popfenlei">{{$t('index.goodsfenlei')}}</text>
  55. </view>
  56. <image class="actimgezy" style="margin-left: 10rpx;" src="/static/images/zuoyouhd.png"
  57. mode="aspectFit"></image>
  58. <view class="">
  59. <swiper style="height: 60rpx;width: 450rpx;align-items: center;" display-multiple-items="2"
  60. :indicator-dots="false" :autoplay="false" :current="current" :duration="500"
  61. @animationfinish="fenleiSel">
  62. <swiper-item v-for="(item,index) in shangpinfenlei">
  63. <view class="swiper-item text1row">{{item.name}}</view>
  64. </swiper-item>
  65. </swiper>
  66. </view>
  67. </view>
  68. </view>
  69. <view v-if="shangpinfenlei.length>0" class="page-view contentColumnC">
  70. <view class="contentInRowC">
  71. <text class="textdop2"></text>
  72. <text class="textdop1"></text>
  73. <text class="text2row"
  74. style="margin-left: 10rpx;font-size: 30rpx;font-weight: bold;max-width: 600rpx;">{{shangpinfenlei[current].name}}</text>
  75. <text class="textdop1"></text>
  76. <text class="textdop2"></text>
  77. </view>
  78. </view>
  79. <view class="page-view contentColumn">
  80. <view class="item_list">
  81. <view class="item_content" v-for="(item1, index1) in shangpinlist" :key="index1">
  82. <view v-if="item1.stackingUp==0" class="thumb-boxR contentColumnC">
  83. <netImage class="goodimage" width="334" height="334" :mysrc="item1.image"
  84. mymode="scaleToFill" v-on:Emyimageclick="shangpinsl(item1.id)"></netImage>
  85. <view class="msText">
  86. <text class="dianpuming" @click="shangpinsl(item1.id)">{{item1.name}}</text>
  87. <view class="buyBT">
  88. <text class="peisongsuoming detailtextV">{{item1.introduce}}</text>
  89. </view>
  90. <view v-if="shangpingoumaiS[current][index1]" class="buyBTSB">
  91. <text class="peisongsuoming">{{$formPr(item1.price)}}{{$t('locale.huobidw')}}</text>
  92. <view v-if="item1.stackingUp==0" class="rconten">
  93. <image v-if="shangpingoumaiS[current][index1].shuliang>0" class="imageRJ"
  94. src="/static/images/jian@3x.png" mode="aspectFit"
  95. @click="jiangouwuche(index1)"></image>
  96. <text v-if="shangpingoumaiS[current][index1].shuliang>0"
  97. class="textR">{{shangpingoumaiS[current][index1].shuliang}}</text>
  98. <image class="imageR" src="/static/images/plus-circle-fill@3x.png"
  99. mode="aspectFit" @click="editSKU(index1)"></image>
  100. </view>
  101. <view v-if="item1.stackingUp==1" class="rconten">
  102. <text class="textR">{{$t('mend.yixiajia')}}</text>
  103. </view>
  104. </view>
  105. </view>
  106. </view>
  107. </view>
  108. </view>
  109. <view style="height: 260rpx;"></view>
  110. </view>
  111. </view>
  112. <!-- <view v-if="dailinghb.length>0" class="hongbaoFV">
  113. <view class="hongbaoImage" @click="openhbkq">
  114. <image src="/static/images/hongbkq.png" style="width: 100%;height: 100%;" mode="aspectFit"></image>
  115. </view>
  116. </view> -->
  117. <view class="bottomfloatV">
  118. <view class="buyBT">
  119. <image class="gouwuche" :src="gouwcheimg" mode="aspectFit" @click="gotoGouwuche"></image>
  120. <text class="peisongsuoming">{{notext}}</text>
  121. <text class="qjs" :style="{backgroundColor:gwbcolor,color:gwbTcolor}"
  122. @click="gotojiesuan">{{$t('comp.qujiesuan')}}</text>
  123. </view>
  124. </view>
  125. <popViewGG :show="showpop" :showbotom="false" :maskClosable="true" :isCancel="true"
  126. @chooseCancel="chooseCancel">
  127. <foodxuangou style="width:100%;max-height: 70vh" :food="spindexSP" v-on:Ejiagouwuche="jiagouwuche">
  128. </foodxuangou>
  129. </popViewGG>
  130. <uni-popup style="z-index: 999;" ref="popfl" type="center" :isMaskClick="true" :safeArea="true">
  131. <view class="contentColumnC" style="width:660upx;background-color:white;border-radius: 8rpx;">
  132. <text class="fenleiTitle"
  133. style="margin-top: 16rpx;margin-bottom: 16rpx;">{{$t('index.goodsfenlei')}}</text>
  134. <scroll-view scroll-y="true" style="max-height: 400rpx;">
  135. <view>
  136. <view class="" v-for="(item,index) in shangpinfenlei">
  137. <view class="fenleiitem" @click="ppfenleisel(index)">{{item.name}}</view>
  138. </view>
  139. </view>
  140. </scroll-view>
  141. <view style="height: 20rpx;"></view>
  142. </view>
  143. </uni-popup>
  144. <popViewGG :show="hongbkqs" :acttips="$t('order.queding')" :maskClosable="true" :isCancel="false"
  145. @chooseCancel="chooseCancel">
  146. <view class="contentColumnC" style="width: 100%;background-color: whitesmoke;">
  147. <view class="contentColumnC" style="height: 80rpx;width: 100%;background-color: lightgray;">
  148. <view class="contentInRowS" style="height: 80rpx;width: 90%;">
  149. <text style="font-size: 30rpx;color: crimson;"></text>
  150. <text style="font-size: 28rpx;">{{$t('index.hongbaokq')}}</text>
  151. <text style="font-size: 30rpx;color: #00A6FF;"
  152. @click="querenyhhd">{{$t('order.queding')}}</text>
  153. </view>
  154. </view>
  155. <view v-if="dailinghb.length>0" style="width: 90%;">
  156. <view class="contentColumn" style="margin-top: 16rpx;" v-for="(item, index) in dailinghb"
  157. :key="index">
  158. <view class="contentInRowS">
  159. <view class="contentColumn withpophbkq"
  160. :style="item.type==0?'color: #00A6FF;':'color:green;'">
  161. <text style="font-size: 28rpx;">{{item.name}}</text>
  162. <text style="font-size: 28rpx;">{{getNote(item,1)}}</text>
  163. </view>
  164. <view class="contentInRowC"
  165. style="width: 150rpx;height:50rpx;background-color:chocolate;border-radius: 6rpx;"
  166. @click="lingququan(item.id)">
  167. <text style="font-size: 26rpx;color: white;">{{$t("hongbaokq.lingqu")}}</text>
  168. </view>
  169. </view>
  170. </view>
  171. </view>
  172. <view style="height: 80rpx;"></view>
  173. </view>
  174. </popViewGG>
  175. <!-- 下载app弹窗 -->
  176. <uni-popup ref="downloadPopup" type="center" :mask-click="true">
  177. <view class="download-popup-content">
  178. <!-- 标题栏 -->
  179. <view class="download-popup-header">
  180. <text class="download-popup-title">{{$t('api.message')}}</text>
  181. <view class="download-popup-close" @click="closeDownloadPopup">
  182. <text class="close-icon">×</text>
  183. </view>
  184. </view>
  185. <!-- 内容 -->
  186. <view class="download-popup-body">
  187. <text class="download-popup-text">{{$t('jiesuan.xiazapp')}}</text>
  188. </view>
  189. <!-- 按钮 -->
  190. <view class="download-popup-buttons">
  191. <view class="download-popup-btn download-popup-btn-ios" @click="downloadIOS">
  192. <text class="download-popup-btn-text">{{$t('jiesuan.xzios')}}</text>
  193. </view>
  194. <view class="download-popup-btn download-popup-btn-android" @click="downloadAndroid">
  195. <text class="download-popup-btn-text">{{$t('jiesuan.xiazandriod')}}</text>
  196. </view>
  197. </view>
  198. </view>
  199. </uni-popup>
  200. </view>
  201. </template>
  202. <script>
  203. import api from "@/pages/api/api.js";
  204. export default {
  205. data() {
  206. return {
  207. isFixedTop: [],
  208. Topdistance: [],
  209. cssName: '',
  210. //------------------------------
  211. cuxiaoImge: [],
  212. id: 1,
  213. userid: 0,
  214. mendianMs: [],
  215. posName: '',
  216. isfirstShow: 0,
  217. isShouchang: 0,
  218. shouchangIcon: '/static/images/faver@3x.png',
  219. option: {},
  220. login: false,
  221. showpop: false,
  222. gouwuche: '',
  223. scrollRightTop: 0, // 右边栏目scroll-view的滚动条高度
  224. shangpinfenlei: [],
  225. shangpinlist: [],
  226. shangpingoumaiS: [],
  227. current: 0, // 当前分类值
  228. spindex: 0, //当前分类商品操作INDEX
  229. spindexSP: '', //当前分类商品操作INDEX对应商品
  230. itemId: 0, // 栏目右边scroll-view用于滚动的id
  231. gouwcheimg: '/static/images/gouwuh@3x.png',
  232. notext: this.$t('comp.weixgsp'),
  233. goumaijine: 0,
  234. gwbcolor: 'darkgray',
  235. gwbTcolor: 'black',
  236. startX: 0,
  237. startY: 0,
  238. lang: '0',
  239. dailinghb: [],
  240. hongbkqs: false,
  241. downloadUrls: {},
  242. isShangjia: 0,
  243. id: 0,
  244. androidPackageName: '', // 安卓应用包名
  245. }
  246. },
  247. onShow() {
  248. if (0 == this.isfirstShow) {
  249. this.getmendianDetail(this.id);
  250. this.isfirstShow = 1;
  251. } else {
  252. this.refleashdata();
  253. }
  254. // this.getHbkaq();
  255. var that = this;
  256. try { //读取
  257. that.token = uni.getStorageSync("token");
  258. //console.log('2222',that.token)
  259. if (that.token == '' || that.token == undefined || that.token == null) {
  260. that.login = false;
  261. return;
  262. } else {
  263. that.login = true;
  264. return;
  265. }
  266. } catch (e) { //错误
  267. return;
  268. }
  269. },
  270. onLoad(option) {
  271. console.log(option)
  272. if (!('id' in option) || !('isShangjia' in option) || !('language' in option)) {
  273. this.$nextTick(() => {
  274. uni.showToast({
  275. title: this.$t('mend.wuxiaofw'),
  276. icon: 'error',
  277. duration: 2000
  278. });
  279. });
  280. return
  281. }
  282. this.isShangjia = option.isShangjia
  283. this.id = option.id
  284. var code = option.language
  285. console.log(code)
  286. uni.setStorageSync('language', code);
  287. uni.setLocale(code);
  288. this.$i18n.locale = code;
  289. var language = uni.getStorageSync('language');
  290. if (language == 'yuenan') {
  291. this.lang = '0';
  292. }
  293. if (language == 'zh-Hans') {
  294. this.lang = '2';
  295. }
  296. if (language == 'zh-Hant') {
  297. this.lang = '3';
  298. }
  299. this.id = option.id;
  300. this.refleashdata();
  301. uni.pageScrollTo({
  302. scrollTop: 0,
  303. duration: 0
  304. })
  305. var info = uni.getSystemInfoSync();
  306. var isAndroid = info.platform.toLowerCase() === 'android';
  307. if (isAndroid) {
  308. this.cssName = 'fixedTop';
  309. } else {
  310. this.cssName = 'fixedTopios';
  311. }
  312. },
  313. mounted() {
  314. this.GetTop()
  315. },
  316. onPageScroll(e) {
  317. const that = this
  318. // console.log(e.scrollTop,JSON.stringify(this.Topdistance),JSON.stringify(this.isFixedTop))
  319. for (let i = 0; i < this.Topdistance.length; i++) {
  320. if (e.scrollTop > this.Topdistance[i] - 70) {
  321. // console.log('***************')
  322. this.isFixedTop[i] = true
  323. this.$set(this.isFixedTop, i, true)
  324. this.isFixedTop[i] = true
  325. } else {
  326. // console.log('++++++++++')
  327. this.isFixedTop[i] = false
  328. this.$set(this.isFixedTop, i, false)
  329. this.isFixedTop[i] = false
  330. }
  331. }
  332. },
  333. methods: {
  334. // 检测是否为安卓设备
  335. isAndroidDevice() {
  336. // 在H5环境中检测
  337. // #ifdef H5
  338. const ua = navigator.userAgent.toLowerCase();
  339. return ua.indexOf('android') > -1;
  340. // #endif
  341. // 在App环境中检测
  342. // #ifdef APP-PLUS
  343. return plus.os.name === 'Android';
  344. // #endif
  345. // 其他环境默认返回false
  346. return false;
  347. },
  348. // 检测是否为iOS设备
  349. isIOSDevice() {
  350. // #ifdef H5
  351. const ua = navigator.userAgent.toLowerCase();
  352. return /iphone|ipad|ipod/.test(ua);
  353. // #endif
  354. // #ifdef APP-PLUS
  355. return plus.os.name === 'iOS';
  356. // #endif
  357. return false;
  358. },
  359. // 显示下载app提示
  360. showDownloadAppModal() {
  361. api('getAppDownload', {}, r => {
  362. console.log(r)
  363. this.downloadUrls = r.data.data;
  364. // 保存安卓包名
  365. if (r.data.data.androidPackageName) {
  366. this.androidPackageName = r.data.data.androidPackageName;
  367. }
  368. this.$refs.downloadPopup.open();
  369. });
  370. },
  371. // 关闭下载app弹窗
  372. closeDownloadPopup() {
  373. this.$refs.downloadPopup.close();
  374. },
  375. // 下载iOS版本
  376. downloadIOS() {
  377. // 先尝试打开已安装的应用
  378. this.tryOpenInstalledApp('cityexpressuser');
  379. this.closeDownloadPopup();
  380. },
  381. // 下载Android版本
  382. downloadAndroid() {
  383. // 先尝试打开已安装的应用
  384. this.tryOpenInstalledApp('deliveryking');
  385. this.closeDownloadPopup();
  386. },
  387. // 尝试打开已安装的应用
  388. tryOpenInstalledApp(schema) {
  389. const that = this;
  390. const appSchema = schema + '://pages/shanpinxungou/shangjia/shangjiaView?id=' + this.id +
  391. '&isShangjia=' + this.isShangjia;
  392. // 在App环境中使用plus.runtime.openURL
  393. // #ifdef APP-PLUS
  394. plus.runtime.openURL(appSchema, function() {
  395. console.log(that.$t('download.app_opened_success'));
  396. }, function(e) {
  397. console.log(that.$t('download.app_not_installed'));
  398. // 应用未安装,继续下载流程
  399. that.startDownloadProcess();
  400. });
  401. // #endif
  402. // 在H5环境中尝试打开应用
  403. // #ifdef H5
  404. this.tryOpenAppInH5(appSchema);
  405. // #endif
  406. },
  407. // 在H5环境中尝试打开应用
  408. tryOpenAppInH5(appSchema) {
  409. const that = this;
  410. // 检测是否为iOS设备
  411. const isIOS = this.isIOSDevice();
  412. if (isIOS) {
  413. // iOS设备使用特殊处理
  414. this.tryOpenIOSApp(appSchema);
  415. } else {
  416. // 安卓设备使用iframe方式
  417. this.tryOpenAndroidApp(appSchema);
  418. }
  419. },
  420. // 尝试打开iOS应用
  421. tryOpenIOSApp(appSchema) {
  422. const that = this;
  423. // 记录开始时间
  424. const startTime = Date.now();
  425. let hasApp = false;
  426. // 监听页面可见性变化
  427. const handleVisibilityChange = () => {
  428. if (document.hidden) {
  429. hasApp = true;
  430. clearTimeout(timeout);
  431. document.removeEventListener('visibilitychange', handleVisibilityChange);
  432. document.removeEventListener('pagehide', handlePageHide);
  433. document.removeEventListener('blur', handleBlur);
  434. }
  435. };
  436. // 监听页面隐藏事件
  437. const handlePageHide = () => {
  438. hasApp = true;
  439. clearTimeout(timeout);
  440. document.removeEventListener('visibilitychange', handleVisibilityChange);
  441. document.removeEventListener('pagehide', handlePageHide);
  442. document.removeEventListener('blur', handleBlur);
  443. };
  444. // 监听窗口失焦事件
  445. const handleBlur = () => {
  446. hasApp = true;
  447. clearTimeout(timeout);
  448. document.removeEventListener('visibilitychange', handleVisibilityChange);
  449. document.removeEventListener('pagehide', handlePageHide);
  450. document.removeEventListener('blur', handleBlur);
  451. };
  452. // 设置超时检测
  453. const timeout = setTimeout(() => {
  454. if (!hasApp) {
  455. // 应用未安装,继续下载流程
  456. that.startDownloadProcess();
  457. }
  458. document.removeEventListener('visibilitychange', handleVisibilityChange);
  459. document.removeEventListener('pagehide', handlePageHide);
  460. document.removeEventListener('blur', handleBlur);
  461. }, 1500); // 缩短超时时间
  462. // 添加事件监听器
  463. document.addEventListener('visibilitychange', handleVisibilityChange);
  464. document.addEventListener('pagehide', handlePageHide);
  465. window.addEventListener('blur', handleBlur);
  466. // 尝试打开应用
  467. try {
  468. // 方法1: 直接使用window.location
  469. window.location.href = appSchema;
  470. } catch (e) {
  471. // 方法2: 使用iframe
  472. const iframe = document.createElement('iframe');
  473. iframe.style.display = 'none';
  474. iframe.style.width = '1px';
  475. iframe.style.height = '1px';
  476. iframe.src = appSchema;
  477. document.body.appendChild(iframe);
  478. // 清理iframe
  479. setTimeout(() => {
  480. if (document.body.contains(iframe)) {
  481. document.body.removeChild(iframe);
  482. }
  483. }, 1000);
  484. }
  485. },
  486. // 尝试打开安卓应用
  487. tryOpenAndroidApp(appSchema) {
  488. const that = this;
  489. let hasApp = false;
  490. // 监听页面可见性变化
  491. const handleVisibilityChange = () => {
  492. if (document.hidden) {
  493. hasApp = true;
  494. clearTimeout(timeout);
  495. document.removeEventListener('visibilitychange', handleVisibilityChange);
  496. document.removeEventListener('pagehide', handlePageHide);
  497. document.removeEventListener('blur', handleBlur);
  498. }
  499. };
  500. // 监听页面隐藏事件
  501. const handlePageHide = () => {
  502. hasApp = true;
  503. clearTimeout(timeout);
  504. document.removeEventListener('visibilitychange', handleVisibilityChange);
  505. document.removeEventListener('pagehide', handlePageHide);
  506. document.removeEventListener('blur', handleBlur);
  507. };
  508. // 监听窗口失焦事件
  509. const handleBlur = () => {
  510. hasApp = true;
  511. clearTimeout(timeout);
  512. document.removeEventListener('visibilitychange', handleVisibilityChange);
  513. document.removeEventListener('pagehide', handlePageHide);
  514. document.removeEventListener('blur', handleBlur);
  515. };
  516. // 设置超时检测
  517. const timeout = setTimeout(() => {
  518. if (!hasApp) {
  519. // 应用未安装,继续下载流程
  520. that.startDownloadProcess();
  521. }
  522. document.removeEventListener('visibilitychange', handleVisibilityChange);
  523. document.removeEventListener('pagehide', handlePageHide);
  524. document.removeEventListener('blur', handleBlur);
  525. }, 1500); // 缩短超时时间
  526. // 添加事件监听器
  527. document.addEventListener('visibilitychange', handleVisibilityChange);
  528. document.addEventListener('pagehide', handlePageHide);
  529. window.addEventListener('blur', handleBlur);
  530. // 尝试打开应用
  531. try {
  532. // 方法1: 直接使用window.location
  533. window.location.href = appSchema;
  534. } catch (e) {
  535. // 方法2: 使用iframe
  536. const iframe = document.createElement('iframe');
  537. iframe.style.display = 'none';
  538. iframe.style.width = '1px';
  539. iframe.style.height = '1px';
  540. iframe.src = appSchema;
  541. document.body.appendChild(iframe);
  542. // 清理iframe
  543. setTimeout(() => {
  544. if (document.body.contains(iframe)) {
  545. document.body.removeChild(iframe);
  546. }
  547. }, 1000);
  548. }
  549. },
  550. // 开始下载流程
  551. startDownloadProcess() {
  552. const that = this;
  553. // 显示下载提示
  554. uni.showLoading({
  555. title: this.$t('download.downloading'),
  556. mask: true
  557. });
  558. // 获取下载链接
  559. api('getAppDownload', {}, r => {
  560. console.log(r);
  561. // 保存安卓包名
  562. if (r.data.data.androidPackageName) {
  563. this.androidPackageName = r.data.data.androidPackageName;
  564. }
  565. // 检测是否为安卓设备
  566. const isAndroid = this.isAndroidDevice();
  567. if (isAndroid) {
  568. // 安卓设备跳转到谷歌商店
  569. that.openGooglePlay('com.deliveryking.user');
  570. } else {
  571. // iOS设备打开App Store
  572. that.openAppStore(r.data.data.iosUrl);
  573. }
  574. });
  575. },
  576. // 打开谷歌商店
  577. openGooglePlay(packageName) {
  578. const that = this;
  579. uni.hideLoading();
  580. if (!packageName) {
  581. // 如果没有包名,提示错误
  582. uni.showToast({
  583. title: 'Package name not found',
  584. icon: 'none',
  585. duration: 2000
  586. });
  587. return;
  588. }
  589. // 构建谷歌商店URL
  590. const googlePlayUrl = `https://play.google.com/store/apps/details?id=${packageName}`;
  591. // 在H5环境中
  592. // #ifdef H5
  593. // 直接跳转到谷歌商店
  594. window.location.href = googlePlayUrl;
  595. // #endif
  596. // 在App环境中
  597. // #ifdef APP-PLUS
  598. plus.runtime.openURL(googlePlayUrl, function(res) {
  599. console.log('Opening Google Play Store success');
  600. }, function(err) {
  601. console.log('Opening Google Play Store failed');
  602. // 如果打开失败,提供手动下载选项
  603. uni.showModal({
  604. title: that.$t('download.download_failed'),
  605. content: that.$t('download.download_failed_manual'),
  606. showCancel: true,
  607. cancelText: that.$t('comp.quxiao'),
  608. confirmText: that.$t('comp.queren'),
  609. success: function(res) {
  610. if (res.confirm) {
  611. // 使用浏览器打开谷歌商店链接
  612. plus.runtime.openURL(googlePlayUrl);
  613. }
  614. }
  615. });
  616. });
  617. // #endif
  618. },
  619. // 下载安卓APK(备用方法)
  620. downloadAndroidAPK(androidUrl) {
  621. const that = this;
  622. // 在App环境中使用plus.downloader
  623. // #ifdef APP-PLUS
  624. const appDownloadTask = plus.downloader.createDownload(androidUrl, {
  625. filename: '_downloads/CTE.apk'
  626. }, function(download, status) {
  627. uni.hideLoading();
  628. if (status === 200) {
  629. // 下载成功,尝试安装
  630. that.installAndroidApp(download.filename);
  631. } else {
  632. uni.showToast({
  633. title: that.$t('download.download_failed'),
  634. icon: 'none',
  635. duration: 2000
  636. });
  637. }
  638. });
  639. // 监听下载进度
  640. appDownloadTask.addEventListener('statechanged', function(download, status) {
  641. if (status === 200) {
  642. const progress = Math.round((download.downloadedSize / download.totalSize) * 100);
  643. uni.showLoading({
  644. title: that.$t('download.downloading_progress', {
  645. progress: progress
  646. }),
  647. mask: true
  648. });
  649. }
  650. });
  651. appDownloadTask.start();
  652. // #endif
  653. // 在H5环境中使用uni.downloadFile
  654. // #ifdef H5
  655. const h5DownloadTask = uni.downloadFile({
  656. url: androidUrl,
  657. success: function(res) {
  658. uni.hideLoading();
  659. if (res.statusCode === 200) {
  660. // 下载成功,尝试安装
  661. that.installAndroidApp(res.tempFilePath);
  662. } else {
  663. uni.showToast({
  664. title: that.$t('download.download_failed'),
  665. icon: 'none',
  666. duration: 2000
  667. });
  668. }
  669. },
  670. fail: function(err) {
  671. uni.hideLoading();
  672. console.log('下载失败:', err);
  673. // 下载失败时,提供手动下载选项
  674. uni.showModal({
  675. title: that.$t('download.download_failed'),
  676. content: that.$t('download.download_failed_manual'),
  677. showCancel: true,
  678. cancelText: that.$t('comp.quxiao'),
  679. confirmText: that.$t('comp.queren'),
  680. success: function(res) {
  681. if (res.confirm) {
  682. // 使用浏览器打开下载链接
  683. window.open(androidUrl, '_blank');
  684. }
  685. }
  686. });
  687. }
  688. });
  689. // 监听下载进度
  690. h5DownloadTask.onProgressUpdate(function(res) {
  691. const progress = Math.round(res.progress);
  692. uni.showLoading({
  693. title: that.$t('download.downloading_progress', {
  694. progress: progress
  695. }),
  696. mask: true
  697. });
  698. });
  699. // #endif
  700. },
  701. // 打开App Store
  702. openAppStore(iosUrl) {
  703. const that = this;
  704. // 在App环境中使用plus.runtime.openURL
  705. // #ifdef APP-PLUS
  706. plus.runtime.openURL(
  707. 'itms-apps://itunes.apple.com/cn/app/cte/id6468907188',
  708. (res) => {
  709. console.log(that.$t('download.app_store_success'))
  710. },
  711. (err) => {
  712. console.log(that.$t('download.app_store_failed'))
  713. // 如果 itms-apps:// 失败,回退到浏览器打开
  714. plus.runtime.openURL('https://apps.apple.com/cn/app/cte/id6468907188')
  715. }
  716. );
  717. // #endif
  718. // 在H5环境中,针对iOS设备优化
  719. // #ifdef H5
  720. // 先尝试直接打开App Store链接
  721. const appStoreUrl = 'https://apps.apple.com/cn/app/cte/id6468907188';
  722. // 尝试多种方式打开App Store
  723. that.tryOpenAppStore(appStoreUrl);
  724. // #endif
  725. },
  726. // 安装安卓应用
  727. installAndroidApp(filePath) {
  728. const that = this;
  729. // 在App环境中,直接尝试安装APK
  730. // #ifdef APP-PLUS
  731. uni.showModal({
  732. title: that.$t('download.download_complete'),
  733. content: that.$t('download.install_confirm'),
  734. showCancel: true,
  735. cancelText: that.$t('comp.quxiao'),
  736. confirmText: that.$t('comp.queren'),
  737. success: function(res) {
  738. if (res.confirm) {
  739. // 使用plus.runtime.install安装APK
  740. plus.runtime.install(filePath, {
  741. force: false
  742. }, function() {
  743. uni.showToast({
  744. title: that.$t('download.install_success'),
  745. icon: 'success',
  746. duration: 2000
  747. });
  748. }, function(e) {
  749. console.log('安装失败:', e);
  750. uni.showModal({
  751. title: that.$t('download.install_failed'),
  752. content: that.$t('download.install_failed_manual'),
  753. showCancel: true,
  754. cancelText: that.$t('comp.quxiao'),
  755. confirmText: that.$t('comp.queren'),
  756. success: function(res) {
  757. if (res.confirm) {
  758. // 打开文件管理器
  759. plus.runtime.openFile(filePath);
  760. }
  761. }
  762. });
  763. });
  764. }
  765. }
  766. });
  767. // #endif
  768. // 在H5环境中,提示用户手动安装
  769. // #ifdef H5
  770. uni.showModal({
  771. title: that.$t('download.download_complete'),
  772. content: that.$t('download.manual_install_hint'),
  773. showCancel: false,
  774. confirmText: that.$t('comp.queren'),
  775. success: function(res) {
  776. if (res.confirm) {
  777. // 尝试打开下载链接,让用户手动下载
  778. window.open(filePath, '_blank');
  779. }
  780. }
  781. });
  782. // #endif
  783. },
  784. // 尝试打开App Store的多种方式
  785. tryOpenAppStore(appStoreUrl) {
  786. // 方法1: 直接使用window.open
  787. const newWindow = window.open(appStoreUrl, '_blank');
  788. // 如果新窗口被阻止,尝试其他方法
  789. if (!newWindow || newWindow.closed || typeof newWindow.closed == 'undefined') {
  790. // 方法2: 尝试使用itms-apps协议
  791. this.tryItmsProtocol();
  792. }
  793. },
  794. // 尝试使用itms-apps协议
  795. tryItmsProtocol() {
  796. const itmsUrl = 'itms-apps://itunes.apple.com/cn/app/cte/id6468907188';
  797. // 创建一个隐藏的iframe来尝试打开itms-apps协议
  798. const iframe = document.createElement('iframe');
  799. iframe.style.display = 'none';
  800. iframe.style.width = '1px';
  801. iframe.style.height = '1px';
  802. iframe.src = itmsUrl;
  803. document.body.appendChild(iframe);
  804. // 设置超时,如果App Store没有打开,则回退到浏览器
  805. setTimeout(() => {
  806. if (document.body.contains(iframe)) {
  807. document.body.removeChild(iframe);
  808. }
  809. // 最后回退到浏览器打开
  810. window.location.href = 'https://apps.apple.com/cn/app/cte/id6468907188';
  811. }, 1500);
  812. },
  813. //选择和领取红包卡券
  814. getHbkaq() {
  815. console.log('1212------------------')
  816. api('userUnclaimedList', {
  817. pageNum: '1',
  818. pageSize: '30',
  819. mdId: this.id
  820. }, res => {
  821. console.log('-----------', res)
  822. if (res.data.code == 200) {
  823. this.dailinghb = res.data.rows;
  824. }
  825. }, failc => {
  826. console.log('getadvertis----', failc)
  827. })
  828. },
  829. openhbkq() {
  830. this.hongbkqs = true;
  831. },
  832. querenyhhd() {
  833. this.hongbkqs = false;
  834. },
  835. getNote(obj, index) {
  836. var str = '';
  837. if (index == 1) {
  838. if (obj.yhfangs == 1 && obj.yhnum > 1) { //优惠方式:1 运费,2 订单 ,3 商品
  839. str = this.$t('hongbaokq.yunfeiyh');
  840. }
  841. if (obj.yhfangs == 1 && obj.yhnum < 1 && obj.yhnum > 0) { //优惠方式:1 运费,2 订单 ,3 商品
  842. str = this.$t('hongbaokq.yunfeizk');
  843. }
  844. if (obj.yhfangs == 1 && obj.yhnum == 0) { //优惠方式:1 运费,2 订单 ,3 商品
  845. str = this.$t('hongbaokq.yunfeiquanm');
  846. }
  847. if (obj.yhfangs == 2 && obj.yhnum > 1) {
  848. str = this.$t('hongbaokq.dingdanyh');
  849. }
  850. if (obj.yhfangs == 2 && obj.yhnum < 1) {
  851. str = this.$t('hongbaokq.dingdanzk');
  852. }
  853. if (obj.yhfangs == 3 && obj.yhnum > 1) {
  854. str = this.$t('hongbaokq.shangpinyh');
  855. }
  856. if (obj.yhfangs == 3 && obj.yhnum < 1) {
  857. str = this.$t('hongbaokq.shangpinzk');
  858. }
  859. if (obj.yhnum != 0) {
  860. str = str + ' ' + obj.yhnum;
  861. }
  862. }
  863. return str;
  864. },
  865. lingququan(id) {
  866. api('userQuanyireceive', {
  867. quanyiId: id,
  868. num: 1
  869. }, r => {
  870. console.log('-----------', r)
  871. if (r.data.code == 200) {
  872. this.getHbkaq();
  873. uni.showToast({
  874. title: this.$t('hongbaokq.lingqucg'),
  875. icon: 'none',
  876. duration: 2500
  877. })
  878. } else {
  879. uni.showToast({
  880. title: this.$t('hongbaokq.lingqushib'),
  881. icon: 'none',
  882. duration: 2500
  883. })
  884. }
  885. }, failc => {
  886. uni.showToast({
  887. title: this.$t('hongbaokq.lingqushib'),
  888. icon: 'none',
  889. duration: 2500
  890. })
  891. //console.log('getadvertis----',failc)
  892. })
  893. },
  894. //----------------------------------------------------
  895. GetTop() {
  896. var _this = this
  897. uni.getSystemInfo({
  898. success: (resu) => {
  899. //console.log('resu',JSON.stringify(resu))
  900. const query = uni.createSelectorQuery().in(this)
  901. query.selectAll('.box').boundingClientRect()
  902. query.selectViewport().scrollOffset()
  903. query.exec(function(res) {
  904. //console.log('res',JSON.stringify(res))
  905. _this.arr(res[0])
  906. })
  907. },
  908. fail: (res) => {}
  909. })
  910. },
  911. arr(res) {
  912. for (let i = 0; i < res.length; i++) {
  913. this.Topdistance[i] = res[i].top
  914. this.isFixedTop[i] = false
  915. }
  916. //console.log('----',JSON.stringify(this.Topdistance))
  917. },
  918. //------------------------------------------------------------------------------
  919. rightF(e) {
  920. //console.log('rightF',e)
  921. this.startX = e.changedTouches[0].pageX;
  922. this.startY = e.changedTouches[0].pageY;
  923. },
  924. leftF(e) {
  925. //console.log('leftF',e)
  926. var s, n;
  927. s = e.changedTouches[0].pageX;
  928. n = e.changedTouches[0].pageY;
  929. var dx, dy;
  930. dx = this.startX - s;
  931. dy = Math.abs(this.startY - n);
  932. if (Math.abs(dx) > 100 && Math.abs(dx) > dy) {
  933. if (dx > 0) {
  934. if (this.current < this.shangpinfenlei.length - 1) {
  935. this.current = this.current + 1;
  936. }
  937. } else {
  938. if (this.current > 0) {
  939. this.current = this.current - 1;
  940. }
  941. }
  942. }
  943. },
  944. fanhui() {
  945. uni.navigateBack();
  946. },
  947. shareToggle() {
  948. this.$refs.share.open()
  949. },
  950. chooseCancel() {
  951. this.showpop = false;
  952. this.hongbkqs = false;
  953. },
  954. fenxiang(item, index) {
  955. this.option = {
  956. //绘制海报内容
  957. //codeUrl: 'https://pic1.zhimg.com/80/v2-2714df42147132464a71af391ed04be4_720w.jpg', //小程序太阳码
  958. codeUrl: '/static/defimages/erweim.png', //小程序太阳码
  959. coverUrl: '/static/defimages/ddd.png', //题库图片
  960. headUrl: '/static/logo.png', //头像
  961. //bgUrl: 'https://pic3.zhimg.com/v2-8fbde0f9ac6a19a23aa839e73394618a_b.jpg', //图片背景填充,和 fillStyle 只能传一个,bgUrl 优先级高于 fillStyle
  962. fillStyle: '#00A6FF', //纯色背景填充颜色
  963. nickName: '跑腿王', //授权登录的用户名
  964. miniName: '不出门吃遍全世界', //小程序名称
  965. tkName: this.posName, //题库名称
  966. tkAuthor: '门店介绍', //题库作者
  967. tkType: '外送', //题库类型
  968. cost: '自取', //是否需要收费 免费/付费
  969. isPub: '堂食' //公开 还是 私有
  970. };
  971. this.$refs.draw.share_qrcode(this.option);
  972. },
  973. shouchang() {
  974. this.showDownloadAppModal();
  975. },
  976. callPhone() {
  977. this.showDownloadAppModal();
  978. },
  979. gengduozx() {
  980. this.showDownloadAppModal();
  981. },
  982. pinglunList() {
  983. this.showDownloadAppModal();
  984. },
  985. fenleiSel(e) {
  986. console.log(e);
  987. this.current = e.detail.current;
  988. this.getmendianshangpinList(this.shangpinfenlei[this.current].id);
  989. this.itemId = 0;
  990. },
  991. shangpinsl(id) {
  992. //选择商品
  993. this.showDownloadAppModal();
  994. },
  995. gotoGouwuche() {
  996. this.showDownloadAppModal();
  997. },
  998. gotojiesuan() {
  999. this.showDownloadAppModal();
  1000. },
  1001. //pop------------------------------------------
  1002. popfenlei() {
  1003. if (this.shangpinfenlei.length > 0) {
  1004. this.$refs.popfl.open('center');
  1005. }
  1006. },
  1007. ppfenleisel(index) {
  1008. this.current = index;
  1009. this.$refs.popfl.close();
  1010. this.getmendianshangpinList(this.shangpinfenlei[this.current].id);
  1011. this.itemId = 0;
  1012. },
  1013. //------------------------------------
  1014. addcollect() {
  1015. if (!this.login) {
  1016. uni.navigateTo({
  1017. url: '/pages/UserCenter/LoginView'
  1018. })
  1019. }
  1020. console.log('addcollect:id', this.id);
  1021. api('addcollect', {
  1022. mdid: this.id
  1023. }, res => {
  1024. console.log(res)
  1025. if (this.isShouchang == 0) {
  1026. this.isShouchang = 1;
  1027. this.shouchangIcon = '/static/images/faverr@3x.png'
  1028. } else {
  1029. this.isShouchang = 0;
  1030. this.shouchangIcon = '/static/images/faver@3x.png'
  1031. }
  1032. }, failc => {
  1033. //console.log('getadvertis----',failc)
  1034. })
  1035. },
  1036. getmendianDetail(id) {
  1037. //console.log('getmendianDetail:id',id);
  1038. uni.showLoading({
  1039. mask: true
  1040. })
  1041. api('getmendianDetail', {
  1042. id: id
  1043. }, r => {
  1044. console.log(r.data.data);
  1045. uni.hideLoading();
  1046. this.mendianMs = r.data.data;
  1047. this.userid = this.mendianMs.userId;
  1048. this.posName = this.mendianMs.posName;
  1049. this.isShouchang = this.mendianMs.Collect;
  1050. if (this.isShouchang == 1) {
  1051. this.shouchangIcon = '/static/images/faverr@3x.png'
  1052. } else {
  1053. this.shouchangIcon = '/static/images/faver@3x.png'
  1054. }
  1055. this.getmendianshangpinFL(id);
  1056. // this.cuxiaoList();
  1057. }, failc => {
  1058. uni.hideLoading();
  1059. //console.log('getadvertis----',failc)
  1060. })
  1061. },
  1062. getmendianshangpinFL(id) {
  1063. uni.showLoading({
  1064. mask: true
  1065. })
  1066. api('getmendianshangpinFL', {
  1067. id: id,
  1068. language: this.lang
  1069. }, res => {
  1070. uni.hideLoading();
  1071. this.shangpinfenlei = res.data.data;
  1072. if (this.shangpinfenlei.length > 0) {
  1073. this.getmendianshangpinList(this.shangpinfenlei[0].id);
  1074. }
  1075. }, failc => {
  1076. uni.hideLoading();
  1077. //console.log('getadvertis----',failc)
  1078. })
  1079. },
  1080. getmendianshangpinList(id) {
  1081. uni.showLoading({
  1082. mask: true
  1083. })
  1084. console.log(this.lang)
  1085. api('getmendianshangpinList', {
  1086. id: id,
  1087. language: this.lang
  1088. }, r => {
  1089. console.log(r);
  1090. uni.hideLoading();
  1091. this.dowithshangpinList(r.data.data);
  1092. this.shangpinlist = r.data.data;
  1093. }, failc => {
  1094. uni.hideLoading();
  1095. //console.log('getadvertis----',failc)
  1096. })
  1097. },
  1098. dowithshangpinList(shangpinlist) {
  1099. if (this.shangpingoumaiS.length == 0) {
  1100. for (var i = 0; i < this.shangpinfenlei.length; i++) {
  1101. this.shangpingoumaiS.push([]);
  1102. }
  1103. }
  1104. this.shangpingoumaiS[this.current] = [];
  1105. if (shangpinlist) {
  1106. for (var j = 0; j < shangpinlist.length; j++) {
  1107. var shuliang = this.tongbugouwuchexinxi(shangpinlist[j]);
  1108. var otherPrice = this.getotherPrice(shangpinlist[j].foodSku);
  1109. var tempSKU = this.gettempSKU(shangpinlist[j].foodSku);
  1110. var tempsp = {
  1111. "shangpin": shangpinlist[j],
  1112. "sku": tempSKU,
  1113. "otherPrice": otherPrice,
  1114. "shuliang": shuliang
  1115. }
  1116. this.shangpingoumaiS[this.current].push(tempsp);
  1117. }
  1118. }
  1119. },
  1120. cuxiaoList() {
  1121. api('cuxiaoList', {
  1122. mdId: this.id,
  1123. price: ''
  1124. }, r => {
  1125. //console.log('-----------',r)
  1126. if (r.data.code == 200) {
  1127. this.cuxiaoImge = [];
  1128. var objs = r.data.data;
  1129. for (var i = 0; i < objs.length; i++) {
  1130. var obj = objs[i];
  1131. if (obj.poster && obj.poster.length > 0) {
  1132. this.cuxiaoImge.push(obj.poster);
  1133. }
  1134. }
  1135. }
  1136. }, failc => {
  1137. //console.log('getadvertis----',failc)
  1138. })
  1139. },
  1140. //--------------------------------------
  1141. tongjigouwuche() {
  1142. this.goumaijine = 0;
  1143. if (this.gouwuche.mendid == this.id) {
  1144. for (var j = 0; j < this.gouwuche.foodlist.length; j++) {
  1145. var sp = this.gouwuche.foodlist[j];
  1146. this.goumaijine = this.goumaijine + sp.number * (sp.price + sp.otherPrice);
  1147. }
  1148. }
  1149. this.jinger();
  1150. },
  1151. tongbugouwuchexinxi(sp) {
  1152. var tempshuliang = 0;
  1153. for (var i = 0; i < this.gouwuche.foodlist.length; i++) {
  1154. if (this.gouwuche.foodlist[i].id == sp.id) {
  1155. tempshuliang = tempshuliang + this.gouwuche.foodlist[i].number;
  1156. }
  1157. }
  1158. return tempshuliang;
  1159. },
  1160. refleashdata() {
  1161. var gwc = uni.getStorageSync('gouwuche');
  1162. if ('' == gwc || null == gwc || undefined == gwc) {
  1163. this.gouwuche = {
  1164. foodlist: [],
  1165. mendid: '',
  1166. userid: '',
  1167. mendname: ''
  1168. };
  1169. this.tongjigouwuche();
  1170. } else {
  1171. this.gouwuche = JSON.parse(gwc);
  1172. this.tongjigouwuche();
  1173. }
  1174. if (this.shangpinlist.length > 0) {
  1175. this.dowithshangpinList(this.shangpinlist);
  1176. }
  1177. },
  1178. jiangouwuche(e) {
  1179. //跳转购物车
  1180. this.showDownloadAppModal();
  1181. },
  1182. jiagouwuche(e) {
  1183. var gwc = uni.getStorageSync('gouwuche');
  1184. if ('' == gwc || null == gwc || undefined == gwc) {
  1185. this.gouwuche = {
  1186. foodlist: [],
  1187. mendid: '',
  1188. userid: '',
  1189. mendname: ''
  1190. };
  1191. } else {
  1192. this.gouwuche = JSON.parse(gwc);
  1193. }
  1194. this.dowithshangpinList(this.shangpinlist);
  1195. this.tongjigouwuche();
  1196. var temp = [];
  1197. for (var i = 0; i < this.shangpinlist.length; i++) {
  1198. temp.push(this.shangpinlist[i]);
  1199. }
  1200. this.shangpinlist = temp;
  1201. this.showpop = false;
  1202. },
  1203. jinger() {
  1204. if (this.goumaijine > 0) {
  1205. this.notext = this.$formPr(this.goumaijine) + this.$t('locale.huobidw');
  1206. console.log(this.notext);
  1207. this.gwbcolor = 'green';
  1208. this.gwbTcolor = 'white';
  1209. this.gouwcheimg = '/static/images/gouwu@3x.png';
  1210. this.showbt = true;
  1211. }
  1212. if (this.goumaijine == 0) {
  1213. this.gwbcolor = 'darkgray';
  1214. this.gwbTcolor = 'black';
  1215. this.notext = this.$t('comp.weixgsp');
  1216. this.gouwcheimg = '/static/images/gouwuh@3x.png';
  1217. this.showbt = false;
  1218. }
  1219. },
  1220. editSKU(index) {
  1221. this.showDownloadAppModal();
  1222. },
  1223. gettempSKU(foodSku) {
  1224. var selectsku = [];
  1225. for (var i = 0; i < foodSku.length; i++) {
  1226. if (foodSku[i].objects.length > 0) {
  1227. for (var j = 0; j < foodSku[i].objects.length; j++) {
  1228. if (foodSku[i].objects[j].state == 1) {
  1229. selectsku.push(foodSku[i].objects[j].name);
  1230. }
  1231. }
  1232. }
  1233. }
  1234. return selectsku;
  1235. },
  1236. getotherPrice(foodSku) {
  1237. var jiner = 0;
  1238. for (var i = 0; i < foodSku.length; i++) {
  1239. if (foodSku[i].objects.length > 0) {
  1240. for (var j = 0; j < foodSku[i].objects.length; j++) {
  1241. if (foodSku[i].objects[j].state == 1) {
  1242. jiner = jiner + parseFloat(foodSku[i].objects[j].price);
  1243. }
  1244. }
  1245. }
  1246. }
  1247. return parseFloat(jiner);
  1248. },
  1249. }
  1250. }
  1251. </script>
  1252. <style lang="scss" scoped>
  1253. page {
  1254. background-color: #F2F3F7;
  1255. }
  1256. .box {
  1257. height: 100upx;
  1258. line-height: 100upx;
  1259. text-align: center;
  1260. background-color: white;
  1261. }
  1262. .fixedTop {
  1263. position: fixed;
  1264. top: 140rpx;
  1265. left: 0;
  1266. right: 0;
  1267. z-index: 9999999;
  1268. }
  1269. .fixedTopios {
  1270. position: fixed;
  1271. top: 180rpx;
  1272. left: 0;
  1273. right: 0;
  1274. z-index: 9999999;
  1275. }
  1276. //-----------------------------
  1277. .nodetail {
  1278. width: 94%;
  1279. margin-left: 3%;
  1280. margin-top: -40rpx;
  1281. background-color: white;
  1282. border-radius: 10rpx;
  1283. }
  1284. .fenleiTitle {
  1285. padding-left: 16rpx;
  1286. padding-right: 16rpx;
  1287. line-height: 36rpx;
  1288. font-size: 28rpx;
  1289. border-radius: 20rpx;
  1290. color: darkgray;
  1291. background-color: white;
  1292. border: 1rpx solid darkgray;
  1293. }
  1294. .swiper-item {
  1295. flex: 1;
  1296. flex-direction: row;
  1297. padding-left: 30rpx;
  1298. font-size: 28rpx;
  1299. line-height: 60rpx;
  1300. text-align: left;
  1301. font-weight: bold;
  1302. text-decoration: underline;
  1303. }
  1304. .textdop1 {
  1305. width: 12rpx;
  1306. height: 12rpx;
  1307. background-color: #00A6FF;
  1308. border-radius: 6rpx;
  1309. margin-left: 10rpx;
  1310. }
  1311. .textdop2 {
  1312. width: 8rpx;
  1313. height: 8rpx;
  1314. background-color: #00A6FF;
  1315. border-radius: 4rpx;
  1316. margin-left: 10rpx;
  1317. }
  1318. .page-view {
  1319. background-color: #F2F3F7;
  1320. }
  1321. .item_list {
  1322. padding: 0 15rpx;
  1323. display: flex;
  1324. flex-wrap: wrap;
  1325. justify-content: flex-start;
  1326. .item_content {
  1327. width: 50%;
  1328. margin: 10rpx 0;
  1329. padding: 14rpx;
  1330. box-sizing: border-box;
  1331. }
  1332. }
  1333. .thumb-boxR {
  1334. width: 334rpx;
  1335. background-color: white;
  1336. }
  1337. .goodimage {
  1338. margin-top: 0rpx;
  1339. }
  1340. .detailtextV {
  1341. width: 90%;
  1342. height: 80rpx;
  1343. overflow: hidden;
  1344. text-overflow: ellipsis;
  1345. display: -webkit-box;
  1346. -webkit-line-clamp: 2;
  1347. -webkit-box-orient: vertical;
  1348. }
  1349. .rconten {
  1350. display: flex;
  1351. flex-direction: row;
  1352. align-items: center;
  1353. margin-left: auto;
  1354. justify-content: flex-end;
  1355. }
  1356. .actimgeCT {
  1357. position: fixed;
  1358. width: 94%;
  1359. left: 3%;
  1360. top: 100rpx;
  1361. z-index: 9;
  1362. }
  1363. .actimge {
  1364. width: 60rpx;
  1365. height: 60rpx;
  1366. }
  1367. .actimgezy {
  1368. width: 40rpx;
  1369. height: 40rpx;
  1370. }
  1371. .imageRJ {
  1372. width: 56rpx;
  1373. height: 56rpx;
  1374. margin-right: 8rpx;
  1375. }
  1376. .imageR {
  1377. width: 56rpx;
  1378. height: 56rpx;
  1379. margin-right: 30rpx;
  1380. }
  1381. .textR {
  1382. margin-left: 6rpx;
  1383. margin-right: 6rpx;
  1384. }
  1385. .msText {
  1386. width: 90%;
  1387. margin-top: 20rpx;
  1388. padding-left: 30rpx;
  1389. text-align: left;
  1390. font-size: 22rpx;
  1391. line-height: 32rpx;
  1392. }
  1393. .buyBT {
  1394. display: flex;
  1395. flex-direction: row;
  1396. justify-content: left;
  1397. align-items: center;
  1398. width: 100%;
  1399. }
  1400. .gouwuche {
  1401. width: 120rpx;
  1402. height: 120rpx;
  1403. }
  1404. .dianpuming {
  1405. font-size: 30rpx;
  1406. line-height: 32rpx;
  1407. height: 32rpx;
  1408. font-weight: bold;
  1409. overflow: hidden;
  1410. text-overflow: ellipsis;
  1411. /* #ifndef APP-PLUS-NVUE */
  1412. display: -webkit-box;
  1413. -webkit-line-clamp: 1;
  1414. -webkit-box-orient: vertical;
  1415. /* #endif */
  1416. }
  1417. .peisongsuoming {
  1418. font-size: 26rpx;
  1419. line-height: 38rpx;
  1420. height: 38rpx;
  1421. color: dimgray;
  1422. }
  1423. .bottomfloatV {
  1424. position: fixed;
  1425. flex-direction: row;
  1426. align-items: center;
  1427. left: 0;
  1428. right: 0;
  1429. bottom: 0;
  1430. z-index: 999;
  1431. background-color: whitesmoke;
  1432. height: 140rpx;
  1433. }
  1434. .qjs {
  1435. border-radius: 8rpx;
  1436. padding: 6rpx;
  1437. margin-left: auto;
  1438. margin-right: 30rpx;
  1439. font-size: 32rpx;
  1440. height: 40rpx;
  1441. line-height: 40rpx;
  1442. }
  1443. .fenleiitem {
  1444. text-align: center;
  1445. margin-top: 12rpx;
  1446. margin-bottom: 12rpx;
  1447. width: 660upx;
  1448. border-radius: 10rpx;
  1449. color: darkblue;
  1450. line-height: 54rpx;
  1451. font-size: 28rpx;
  1452. border: solid lavender;
  1453. border-width: 0px 0px 1rpx 0px;
  1454. }
  1455. .hongbaoFV {
  1456. position: fixed;
  1457. flex-direction: row;
  1458. align-items: center;
  1459. left: 50rpx;
  1460. top: 400rpx;
  1461. z-index: 9999;
  1462. height: 120rpx;
  1463. width: 120rpx;
  1464. }
  1465. .hongbaoImage {
  1466. height: 120rpx;
  1467. width: 120rpx;
  1468. }
  1469. .withpophbkq {
  1470. width: 80%;
  1471. }
  1472. /* 下载app弹窗样式 */
  1473. .download-popup-content {
  1474. width: 600rpx;
  1475. background-color: white;
  1476. border-radius: 16rpx;
  1477. overflow: hidden;
  1478. }
  1479. .download-popup-header {
  1480. display: flex;
  1481. flex-direction: row;
  1482. justify-content: space-between;
  1483. align-items: center;
  1484. padding: 40rpx 40rpx 20rpx 40rpx;
  1485. position: relative;
  1486. }
  1487. .download-popup-title {
  1488. font-size: 36rpx;
  1489. font-weight: bold;
  1490. color: #333;
  1491. text-align: center;
  1492. flex: 1;
  1493. }
  1494. .download-popup-close {
  1495. position: absolute;
  1496. right: 0;
  1497. top: 0;
  1498. width: 60rpx;
  1499. height: 60rpx;
  1500. display: flex;
  1501. align-items: center;
  1502. justify-content: center;
  1503. border-radius: 0 16rpx 0 8rpx;
  1504. background-color: #ff4444;
  1505. }
  1506. .close-icon {
  1507. font-size: 40rpx;
  1508. color: white;
  1509. line-height: 1;
  1510. }
  1511. .download-popup-body {
  1512. padding: 20rpx 40rpx 40rpx 40rpx;
  1513. text-align: center;
  1514. }
  1515. .download-popup-text {
  1516. font-size: 30rpx;
  1517. color: #666;
  1518. line-height: 1.5;
  1519. }
  1520. .download-popup-buttons {
  1521. display: flex;
  1522. flex-direction: row;
  1523. border-top: 1rpx solid #f0f0f0;
  1524. }
  1525. .download-popup-btn {
  1526. flex: 1;
  1527. height: 100rpx;
  1528. display: flex;
  1529. align-items: center;
  1530. justify-content: center;
  1531. position: relative;
  1532. }
  1533. .download-popup-btn:not(:last-child)::after {
  1534. content: '';
  1535. position: absolute;
  1536. right: 0;
  1537. top: 0;
  1538. bottom: 0;
  1539. width: 1rpx;
  1540. background-color: #f0f0f0;
  1541. }
  1542. .download-popup-btn-ios {
  1543. background-color: white;
  1544. }
  1545. .download-popup-btn-android {
  1546. background-color: white;
  1547. }
  1548. .download-popup-btn-text {
  1549. font-size: 32rpx;
  1550. }
  1551. .download-popup-btn-ios .download-popup-btn-text {
  1552. color: #666;
  1553. }
  1554. .download-popup-btn-android .download-popup-btn-text {
  1555. color: #007AFF;
  1556. font-weight: 500;
  1557. }
  1558. </style>