shopsList.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. <template>
  2. <div>
  3. <!-- <div style="float: right;margin-right:2%;">
  4. <el-button :disabled="!isAuth('shopsListSm:add')" icon="document" size="mini" style="margin: 10px 0;" type="primary"
  5. @click="addNotice">添加</el-button>
  6. </div> -->
  7. <el-button style="margin-left:15px;" size="mini" type="primary" icon="document" @click="cleans2">刷新
  8. </el-button>
  9. <el-table v-loading="tableDataLoading" :data="typeDatas.list" row-key="id">
  10. <el-table-column label="编号" prop="shopId" width="80">
  11. </el-table-column>
  12. <el-table-column label="名称" prop="shopName">
  13. </el-table-column>
  14. <el-table-column prop="goodsCover" label="轮播图" width="150">
  15. <template slot-scope="scope">
  16. <!-- <img :src="scope.row.goodsCover" alt="" width="60" height="60"> -->
  17. <div v-for="(item,index) in scope.row.shopBanner" :key="index" style="display: inline-block; margin: 3px;">
  18. <el-popover placement="top-start" title="" trigger="hover">
  19. <img style="width: 50px; height: 50px" :src="item" alt="" slot="reference">
  20. <img style="width: 300px; height: auto" :src="item" alt="">
  21. </el-popover>
  22. </div>
  23. </template>
  24. </el-table-column>
  25. <el-table-column label="开店时间" prop="openTime">
  26. </el-table-column>
  27. <el-table-column label="闭店时间" prop="closeTime">
  28. </el-table-column>
  29. <el-table-column label="地址" prop="detailedAddress">
  30. </el-table-column>
  31. <el-table-column label="经度" prop="shopLng">
  32. </el-table-column>
  33. <el-table-column label="纬度" prop="shopLat">
  34. </el-table-column>
  35. <el-table-column label="店铺二维码" width="100">
  36. <template slot-scope="scope">
  37. <el-button size="mini" type="primary"
  38. @click="erweima(scope.row)"style="margin: 5px;">查看
  39. </el-button>
  40. </template>
  41. </el-table-column>
  42. <el-table-column label="操作" width="220">
  43. <template slot-scope="scope">
  44. <el-button size="mini" type="primary" @click="shopsListAdmin(scope.row)" style="margin: 5px;">商品列表
  45. </el-button>
  46. <el-button :disabled="!isAuth('shopsListSm:update')" size="mini" type="primary"
  47. @click="updates(scope.$index, scope.row)"style="margin: 5px;">修改
  48. </el-button>
  49. <el-button size="mini" type="primary" @click="shopsListOrder(scope.row)" style="margin: 5px;">订单列表
  50. </el-button>
  51. <!-- <el-button :disabled="!isAuth('shopsListSm:delete')" size="mini" type="danger" @click="deletes(scope.row)" style="margin: 5px;">删除
  52. </el-button> -->
  53. <el-button size="mini" type="primary" @click="shopsListSr(scope.row)" style="margin: 5px;">收入统计
  54. </el-button>
  55. </template>
  56. </el-table-column>
  57. </el-table>
  58. <div style="text-align: center;margin-top: 10px;">
  59. <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :page-sizes="[10, 20, 30, 50, 100]"
  60. :page-size="limit" :current-page="page" layout="total,sizes, prev, pager, next,jumper"
  61. :total="typeDatas.totalCount">
  62. </el-pagination>
  63. </div>
  64. <!-- 添加分类 -->
  65. <el-dialog :visible.sync="dialogFormVisible" center :title="titles">
  66. <div style="margin-bottom: 10px;">
  67. <span style="width: 200px;display: inline-block;text-align: right;">店铺名称:</span>
  68. <el-input v-model="shopName" placeholder="请输入店铺名称" style="width:50%;"></el-input>
  69. </div>
  70. <div style="margin-bottom: 10px;display:flex;">
  71. <span style="width: 200px;display: inline-block;text-align: right;">轮播图:</span>
  72. <div class="imgs" v-for="(item,index) in img" :key="index">
  73. <img width="100%" class="images" height="100%" :src="item" alt="">
  74. <span class="dels">
  75. <i class="el-icon-delete" @click="dels(index)"></i>
  76. </span>
  77. </div>
  78. <div class="imgs" style="width: 50%;">
  79. <el-upload :action="Tupiantou" :headers="{ token: token }" list-type="picture-card"
  80. :show-file-list="false" :on-success="handleRemove" :on-progress="onprogress1">
  81. <el-progress v-if="percentage1>0 && percentage1<100" type="circle" :percentage="percentage1"></el-progress>
  82. <i v-else class="el-icon-plus"></i>
  83. </el-upload>
  84. <el-dialog :visible.sync="dialogVisible">
  85. <img width="100%" :src="dialogImageUrl" alt="">
  86. </el-dialog>
  87. </div>
  88. </div>
  89. <div style="margin-bottom: 10px;">
  90. <span style="width: 200px;display: inline-block;text-align: right;">开店时间:</span>
  91. <!-- <el-input v-model="openTime" placeholder="请输入排序号" type="data" min="0" style="width:50%;"></el-input> -->
  92. <el-time-select v-model="openTime" :picker-options="{
  93. start: '00:00',
  94. step: '00:15',
  95. end: '24:00'
  96. }" placeholder="选择开店时间" style="width:50%;">
  97. </el-time-select>
  98. </div>
  99. <div style="margin-bottom: 10px;">
  100. <span style="width: 200px;display: inline-block;text-align: right;">闭店时间:</span>
  101. <!-- <el-input v-model="closeTime" placeholder="请输入排序号" type="data" min="0" style="width:50%;"></el-input> -->
  102. <el-time-select v-model="closeTime" :picker-options="{
  103. start: '00:00',
  104. step: '00:15',
  105. end: '24:00'
  106. }" placeholder="选择开店时间" style="width:50%;">
  107. </el-time-select>
  108. </div>
  109. <div style="margin-bottom: 10px;">
  110. <span style="width: 200px;display: inline-block;text-align: right;">店铺地址:</span>
  111. <el-input v-model="detailedAddress" placeholder="请输入店铺地址" type="text" style="width:50%;"></el-input>
  112. </div>
  113. <div style="margin-bottom: 10px;">
  114. <span style="width: 200px;display: inline-block;text-align: right;">纬度:</span>
  115. <el-input v-model="latitude" style="width:50%;" placeholder="请输入纬度"></el-input>
  116. </div>
  117. <div style="margin-bottom: 10px;">
  118. <span style="width: 200px;display: inline-block;text-align: right;">经度:</span>
  119. <el-input v-model="longitude" style="width:50%;" placeholder="请输入经度"></el-input>
  120. </div>
  121. <div>
  122. <div id="container1" style="width:80%;height:500px;margin-left: 10%;"></div>
  123. </div>
  124. <div slot="footer" class="dialog-footer">
  125. <el-button @click="dialogFormVisible = false">取 消</el-button>
  126. <el-button type="primary" @click="releasNoticeTo()">确 定</el-button>
  127. </div>
  128. </el-dialog>
  129. <!-- 店铺二维码 -->
  130. <el-dialog :visible.sync="dialogFormVisible2" center title="店铺二维码">
  131. <div>
  132. <img :src="erweimaImg" style="width: 50%;margin-left: 25%;" />
  133. <div style="text-align: center;margin-top: 20px;">
  134. <el-button type="primary" @click="chakan()">打开窗口查看</el-button>
  135. </div>
  136. </div>
  137. </el-dialog>
  138. </div>
  139. </template>
  140. <script>
  141. import Vue from "vue";
  142. import {
  143. jsonp
  144. } from 'vue-jsonp'
  145. var geocoder, map, markersArray = [];
  146. export default {
  147. data() {
  148. return {
  149. token: "",
  150. limit: 10,
  151. page: 1,
  152. shopId: '',
  153. shopName: '',
  154. openTime: '',
  155. closeTime: '',
  156. detailedAddress: '',
  157. shopLng: '',
  158. shopLat: '',
  159. img: '',
  160. classn: '',
  161. value: [],
  162. parentId: 0,
  163. parentIdnum: '',
  164. tableDataLoading: false,
  165. dialogFormVisible1: false,
  166. dialogFormVisible: false,
  167. dialogFormVisible2:false,
  168. typeDatas: [],
  169. titles:'添加',
  170. // 地图相关
  171. longitude: '', //维度
  172. latitude: '', //经度
  173. loadingMap: true,
  174. BMap: '',
  175. map: '',
  176. geoc: '',
  177. keyword: '',
  178. showMap: false,
  179. pointLngLat: '',
  180. center: {
  181. lng: 109.45744048529967,
  182. lat: 36.49771311230842
  183. },
  184. storeAddress: [],
  185. storeAddre: '请选择城市',
  186. form: {
  187. province: '',
  188. city: '', //市
  189. district: '', //区
  190. },
  191. percentage1: 0, //进度条
  192. img: [], //任务轮播图
  193. dialogImageUrl: [],
  194. dialogVisible: false,
  195. erweimaImg:''
  196. }
  197. },
  198. methods: {
  199. handleSizeChange(val) {
  200. this.limit = val
  201. this.dataSelect()
  202. },
  203. handleCurrentChange(val) {
  204. this.page = val
  205. this.dataSelect()
  206. },
  207. // 图标上传
  208. handleAvatarSuccess(file) {
  209. this.img = file.data
  210. },
  211. // 添加分类弹框
  212. addNotice() {
  213. this.titles = '添加'
  214. this.shopId = ''
  215. this.shopName = ''
  216. this.openTime = ''
  217. this.closeTime = ''
  218. this.dialogImageUrl = []
  219. this.img = []
  220. this.detailedAddress = ''
  221. this.shopLng = ''
  222. this.shopLat = ''
  223. this.longitude= '' //维度
  224. this.latitude= '' //经度
  225. this.dialogFormVisible = true
  226. this.getMyLocation();
  227. },
  228. // 添加分类
  229. releasNoticeTo() {
  230. if (this.shopName == '') {
  231. this.$notify({
  232. title: '提示',
  233. duration: 1800,
  234. message: '请输入店铺名称',
  235. type: 'warning'
  236. })
  237. return
  238. }
  239. if (this.openTime == '') {
  240. this.$notify({
  241. title: '提示',
  242. duration: 1800,
  243. message: '请选择开店时间',
  244. type: 'warning'
  245. })
  246. return
  247. }
  248. if (this.closeTime == '') {
  249. this.$notify({
  250. title: '提示',
  251. duration: 1800,
  252. message: '请选择闭店时间',
  253. type: 'warning'
  254. })
  255. return
  256. }
  257. if (this.detailedAddress == '') {
  258. this.$notify({
  259. title: '提示',
  260. duration: 1800,
  261. message: '请输入店铺地址',
  262. type: 'warning'
  263. })
  264. return
  265. }
  266. if (this.longitude == '' || this.latitude=='') {
  267. this.$notify({
  268. title: '提示',
  269. duration: 1800,
  270. message: '请在地图上定位获取经纬度',
  271. type: 'warning'
  272. })
  273. return
  274. }
  275. var datas = {}
  276. datas.shopName = this.shopName
  277. datas.shopBanner = this.img.toString()
  278. datas.openTime = this.openTime
  279. datas.closeTime = this.closeTime
  280. datas.detailedAddress = this.detailedAddress
  281. datas.shopLng = this.longitude
  282. datas.shopLat = this.latitude
  283. if(this.titles=='添加'){
  284. var url = 'admin/goods/insertGoodsShop'
  285. }
  286. if(this.titles=='修改'){
  287. var url = 'admin/goods/updateGoodsShop'
  288. datas.shopId = this.shopId
  289. }
  290. this.$http({
  291. url: this.$http.adornUrl(url),
  292. method: 'post',
  293. data: this.$http.adornData(datas)
  294. }).then(({
  295. data
  296. }) => {
  297. this.dialogFormVisible = false
  298. this.$message({
  299. message: '操作成功',
  300. type: 'success',
  301. duration: 1500,
  302. onClose: () => {
  303. this.dataSelect()
  304. }
  305. })
  306. })
  307. },
  308. // 修改弹框
  309. updates(index, rows) {
  310. this.titles = '修改'
  311. this.shopId = rows.shopId
  312. this.shopName = rows.shopName
  313. this.openTime = rows.openTime
  314. this.closeTime = rows.closeTime
  315. if (rows.shopBanner) {
  316. this.dialogImageUrl = rows.shopBanner
  317. this.img = rows.shopBanner
  318. }
  319. this.detailedAddress = rows.detailedAddress
  320. this.shopLng = rows.shopLng
  321. this.shopLat = rows.shopLat
  322. this.longitude= rows.shopLng //维度
  323. this.latitude= rows.shopLat //经度
  324. this.getMyLocation();
  325. this.dialogFormVisible = true
  326. },
  327. // 查看二维码
  328. erweima(row){
  329. this.dialogFormVisible2 = true
  330. this.erweimaImg = this.$http.adornUrl('invite/shopQr?shopId='+row.shopId)
  331. },
  332. chakan(){
  333. window.open(this.erweimaImg, '_blank');
  334. },
  335. // 删除分类
  336. deletes(row) {
  337. // if (row.children == null || row.children.length == 0) {
  338. this.$confirm(`确定删除此条信息?`, '提示', {
  339. confirmButtonText: '确定',
  340. cancelButtonText: '取消',
  341. type: 'warning'
  342. }).then(() => {
  343. this.$http({
  344. url: this.$http.adornUrl('admin/goods/deleteGoodsShop'),
  345. method: 'get',
  346. params: this.$http.adornParams({
  347. 'id': row.shopId
  348. })
  349. }).then(({
  350. data
  351. }) => {
  352. this.$message({
  353. message: '删除成功',
  354. type: 'success',
  355. duration: 1500,
  356. onClose: () => {
  357. this.dataSelect()
  358. }
  359. })
  360. })
  361. }).catch(() => {})
  362. // } else {
  363. // this.$message({
  364. // message: '请先删除',
  365. // type: 'error',
  366. // duration: 1500,
  367. // })
  368. // return
  369. // }
  370. },
  371. // 商品类别
  372. shopsListAdmin(row){
  373. this.$router.push({
  374. path: '/shopsListAdminSm',
  375. query: {
  376. shopId: row.shopId
  377. }
  378. })
  379. },
  380. // 订单列表
  381. shopsListOrder(row){
  382. this.$router.push({
  383. path: '/shopsOrderSm',
  384. query: {
  385. shopId: row.shopId
  386. }
  387. })
  388. },
  389. // 收入统计
  390. shopsListSr(row){
  391. this.$router.push({
  392. path: '/shopDatasSm',
  393. query: {
  394. shopId: row.shopId
  395. }
  396. })
  397. },
  398. // 获取分类数据
  399. dataSelect() {
  400. this.tableDataLoading = true
  401. this.$http({
  402. url: this.$http.adornUrl('admin/goods/selectAllShop'),
  403. method: 'get',
  404. params: this.$http.adornParams({
  405. 'page': this.page,
  406. 'limit': this.limit,
  407. 'shopName': ''
  408. })
  409. }).then(({
  410. data
  411. }) => {
  412. this.tableDataLoading = false
  413. for (var i in data.data.list) {
  414. if (data.data.list[i].shopBanner) {
  415. data.data.list[i].shopBanner = data.data.list[i].shopBanner.split(',')
  416. }
  417. }
  418. let returnData = data.data
  419. this.typeDatas = returnData
  420. })
  421. },
  422. //定位获得当前位置信息
  423. getMyLocation() {
  424. var geolocation = new qq.maps.Geolocation("ZBABZ-ZWECU-UQTVV-4LYDR-COK3F-5SF75", "来点小收入");
  425. geolocation.getIpLocation(this.showPosition, this.showErr);
  426. // geolocation.getLocation(this.showPosition, this.showErr);//或者用getLocation精确度比较高
  427. },
  428. showPosition(position) {
  429. console.log(position);
  430. // this.latitude = position.lat;
  431. // this.longitude = position.lng;
  432. // this.city = position.city;
  433. this.setMap();
  434. },
  435. showErr(e) {
  436. console.log("定位失败", e);
  437. this.getMyLocation(); //定位失败再请求定位,测试使用
  438. },
  439. //位置信息在地图上展示
  440. setMap() {
  441. //步骤:定义map变量 调用 qq.maps.Map() 构造函数 获取地图显示容器
  442. //设置地图中心点
  443. var myLatlng = new qq.maps.LatLng(this.latitude, this.longitude);
  444. //定义工厂模式函数
  445. var myOptions = {
  446. zoom: 13, //设置地图缩放级别
  447. center: myLatlng, //设置中心点样式
  448. mapTypeId: qq.maps.MapTypeId.ROADMAP //设置地图样式详情参见MapType
  449. }
  450. // //获取dom元素添加地图信息
  451. var map = new qq.maps.Map(document.getElementById("container1"), myOptions);
  452. //给地图添加点击事件
  453. //给定位的位置添加图片标注
  454. var marker = new qq.maps.Marker({
  455. position: myLatlng,
  456. map: map
  457. });
  458. // `````````````
  459. var that = this;
  460. if (that.longitude == '') {
  461. var center = new qq.maps.LatLng(34.34281541842994, 108.93970884382725);
  462. } else {
  463. var center = new qq.maps.LatLng(that.latitude, that.longitude);
  464. }
  465. var map = new qq.maps.Map(document.getElementById("container1"), {
  466. center: center,
  467. zoom: 13
  468. });
  469. var marker = new qq.maps.Marker({
  470. position: center,
  471. map: map
  472. });
  473. var latlngBounds = new qq.maps.LatLngBounds();
  474. qq.maps.event.addListener(map, "click", function(event) {
  475. console.log(event, qq.maps);
  476. that.longitude = event.latLng.getLng(); // 经度
  477. that.latitude = event.latLng.getLat(); // 纬度
  478. jsonp('https://apis.map.qq.com/ws/geocoder/v1/?location=' + event.latLng.getLat() + ',' + event.latLng
  479. .getLng() + '&key=ZBABZ-ZWECU-UQTVV-4LYDR-COK3F-5SF75&get_poi=1&output=jsonp', {
  480. myCustomUrlParam: 'veryNice'
  481. }).then(response => {
  482. console.log('response', response, response.result.formatted_addresses.recommend)
  483. that.detailedAddress = response.result.formatted_addresses.recommend
  484. }).catch(error => {
  485. // handle error
  486. }).then(() => {
  487. // always executed
  488. });
  489. if (markersArray) {
  490. for (let i in markersArray) {
  491. markersArray[i].setMap(null);
  492. }
  493. }
  494. var marker = new qq.maps.Marker({
  495. map: map,
  496. position: event.latLng
  497. });
  498. markersArray.push(marker);
  499. });
  500. geocoder = new qq.maps.Geocoder({
  501. complete: function(result) {
  502. console.log(result);
  503. that.longitude = result.detail.location.lng;
  504. that.latitude = result.detail.location.lat;
  505. map.setCenter(result.detail.location);
  506. var marker = new qq.maps.Marker({
  507. map: map,
  508. position: result.detail.location
  509. });
  510. markersArray.push(marker);
  511. }
  512. });
  513. },
  514. // 地图定位
  515. select() {
  516. console.log(this.detailedAddress)
  517. // this.address = this.province+ this.city+this.district+this.address
  518. var addr = this.province + this.city + this.district + this.address
  519. let that = this
  520. jsonp('https://apis.map.qq.com/ws/geocoder/v1/?address==' + addr +
  521. '&key=ZBABZ-ZWECU-UQTVV-4LYDR-COK3F-5SF75&get_poi=1&output=jsonp', {
  522. myCustomUrlParam: 'veryNice'
  523. }).then(response => {
  524. // handle success
  525. console.log('response', response)
  526. that.longitude = response.result.location.lng; // 经度
  527. that.latitude = response.result.location.lat; // 纬度
  528. // that.address = response.result.title
  529. that.setMap()
  530. }).catch(error => {
  531. // handle error
  532. }).then(() => {
  533. // always executed
  534. });
  535. },
  536. onprogress1(event, file, fileList) {
  537. console.log('详情图上传进度', parseInt(event.percent))
  538. this.percentage1 = parseInt(event.percent)
  539. },
  540. // 轮播图片上传
  541. handleRemove(file) {
  542. console.log(file, this.img)
  543. this.img.push(file.data);
  544. },
  545. handleDownload(file) {
  546. console.log(file, this.img)
  547. },
  548. // 删除轮播图
  549. dels(index) {
  550. this.img.splice(index, 1);
  551. console.log(this.img)
  552. },
  553. cleans2(){
  554. this.dataSelect()
  555. }
  556. },
  557. mounted() {
  558. this.token = Vue.cookie.get("token");
  559. this.dataSelect()
  560. },
  561. watch: {
  562. '$route':'dataSelect'
  563. }
  564. }
  565. </script>
  566. <style>
  567. .imgs {
  568. position: relative;
  569. border-radius: 6px;
  570. width: 148px;
  571. height: 148px;
  572. margin-right: 10px;
  573. display: inline-block;
  574. }
  575. .dels {
  576. position: absolute;
  577. top: 0;
  578. left: 0;
  579. display: none;
  580. }
  581. .dels .el-icon-delete {
  582. line-height: 148px;
  583. padding-left: 58px;
  584. font-size: 25px;
  585. color: #fff;
  586. }
  587. .imgs:hover .dels {
  588. width: 100%;
  589. height: 100%;
  590. background: #000;
  591. display: block;
  592. opacity: 0.5;
  593. }
  594. </style>