newdizhi.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. <template>
  2. <view class="contentV">
  3. <customNav :shownav="true" :title="$t('index.shouhuodz')" titledetl=""></customNav>
  4. <view class="topaddrCTV bottomline">
  5. <view class="contentInRowS" @click="selectDizhi">
  6. <view class="contentColumn">
  7. <text class="areaT textfontB4">{{area}}</text>
  8. <text class="addressT textfontB5">{{xingzhengqw}}</text>
  9. </view>
  10. <image class="slot-image" src="/static/images/dizhil@3x.png" mode="widthFix"></image>
  11. </view>
  12. </view>
  13. <text class="linesp"></text>
  14. <view class="inputctV">
  15. <text>{{$t('index.xiangxidz')}}</text>
  16. <input class="inputV" type="text" :disabled="jinzhishur" :value="address" :placeholder="$t('index.qsrxiangxidz')" @input="addressinput">
  17. </view>
  18. <text class="linesp"></text>
  19. <view class="inputctV">
  20. <text>{{$t('index.lianxiren')}}</text>
  21. <view class="ctinrow">
  22. <input class="inputV" type="text" :disabled="jinzhishur" :value="name" :placeholder="$t('index.qsrlianxiren')" @input="nameinput">
  23. <!-- <radio-group @change="radioChange">
  24. <radio value="y" />
  25. {{$t('index.xiansheng')}}
  26. <radio value="x"/>
  27. {{$t('index.nvshi')}}
  28. </radio-group> -->
  29. </view>
  30. </view>
  31. <text class="linesp"></text>
  32. <view class="inputctV">
  33. <text>{{$t('order.lianxidianhua')}}</text>
  34. <view class="ctinrow">
  35. <!-- <view class="xialakuang" @click="popgjm">
  36. <text>{{guojiadaima}}</text>
  37. <image style="width: 36rpx;height: 36rpx;padding-right: 16rpx;" src="/static/images/xiala@3x.png" mode="scaleToFill"></image>
  38. </view> -->
  39. <input class="inputphone" type="number" :disabled="jinzhishur" :value="phone" :placeholder="$t('index.shoujihao')" @input="phoneinput">
  40. </view>
  41. </view>
  42. <view class="contentInRowL" style="margin-left: 5%;margin-top: 50rpx;">
  43. <text>{{$t('order.menpaizp')}}</text>
  44. </view>
  45. <view class="contentColumnC" style="margin-top: 30rpx;">
  46. <yhdslCropper ref="yhdslCropper" :quality="1" mode="scale" @uploadImg="uploadImg" :scale="scale"></yhdslCropper>
  47. <image class="imagV" :src="baseUrl+mpImage" mode="scaleToFill" @click="selectImage"></image>
  48. </view>
  49. <view class="contentColumnC" style="margin-top: 50rpx;">
  50. <text class="savebt" @click="updataAddr">{{$t('index.tijiao')}}</text>
  51. <text v-if="id>=0" class="delbt" @click="deleteAddr">{{$t('index.sanchu')}}</text>
  52. </view>
  53. <view style="height: 60rpx;"></view>
  54. <popViewGG :tips="$t('index.gjqhxz')" :show="showpop" :acttips="$t('order.queding')" :maskClosable="true" :isCancel="true" @chooseCancel="chooseCancel">
  55. <picker-view :indicator-style="indicatorStyle" :value="pvalue" @change="bindChange" class="picker-view">
  56. <picker-view-column>
  57. <view class="item" v-for="(item,index) in range" :key="index">{{item}}</view>
  58. </picker-view-column>
  59. </picker-view>
  60. </popViewGG>
  61. </view>
  62. </template>
  63. <script>
  64. import yhdslCropper from '@/components/yhdsl-cropper/yhdsl-cropper.vue';
  65. import api from "@/pages/api/api.js"
  66. export default {
  67. components: {
  68. yhdslCropper
  69. },
  70. data() {
  71. return {
  72. pvalue: [0],
  73. indicatorStyle: `height: 50px;`,
  74. range: ["+86","+84","+886"],
  75. showpop:false,
  76. guojiadaima:'+86',
  77. latitude: 0,
  78. longitude: 0,
  79. country:'',
  80. province:'',
  81. city: "",
  82. area: '',
  83. address: "",
  84. phone:'',
  85. name:'',
  86. annexes:'',
  87. id:-1,
  88. xingzhengqw:this.$t('mend.qingxzdz'),
  89. jinzhishur:false,
  90. scale:1,
  91. baseUrl:this.$baseImagurl,
  92. mpImage:''
  93. }
  94. },
  95. onLoad(option) {
  96. this.id = option.id;
  97. if(this.id>=0){
  98. this.getaddressxq(this.id);
  99. }
  100. },
  101. onShow() {
  102. this.gettempLocate();
  103. if(this.latitude==0||this.longitude==0){
  104. this.jinzhishur=true;
  105. }
  106. else{
  107. this.jinzhishur=false;
  108. }
  109. },
  110. methods: {
  111. radioChange(e){
  112. console.log(e.detail.value)
  113. },
  114. bindChange (e) {
  115. var val = e.detail.value[0];
  116. this.guojiadaima=this.range[val];
  117. },
  118. popgjm(){
  119. this.showpop=true;
  120. },
  121. chooseCancel(){
  122. this.showpop=false;
  123. },
  124. addressinput(event){
  125. this.address = event.target.value;
  126. },
  127. nameinput(event){
  128. this.name = event.target.value;
  129. },
  130. phoneinput(event){
  131. this.phone = event.target.value;
  132. },
  133. selectDizhi(){
  134. // uni.navigateTo({
  135. // url:'/pages/UserCenter/map/mapN?state=2'
  136. // })
  137. uni.navigateTo({
  138. url:'/pages/UserCenter/map/Chazhaodizhi'
  139. })
  140. },
  141. gettempLocate(){
  142. try {//读取
  143. var data = uni.getStorageSync("tempLocation");
  144. if(''==data || undefined==data || null==data){
  145. return;
  146. }
  147. else{
  148. this.latitude=data.latitude;
  149. this.longitude=data.longitude;
  150. this.address=data.address;
  151. this.xingzhengqw=data.address;
  152. this.area=data.name;
  153. uni.setStorageSync('userAddrLocation',"");
  154. uni.setStorageSync('tempLocation',"");
  155. return;
  156. }
  157. } catch(e){//错误
  158. return;
  159. }
  160. },
  161. selectImage(){
  162. this.$refs.yhdslCropper.chooseImage();
  163. },
  164. uploadImg(e) {
  165. console.log('------------uploadImg:',e)
  166. this.spImage = e;
  167. var that = this;
  168. uni.uploadFile({
  169. url: this.$upImagurl, //上传图片api
  170. filePath: e,
  171. name: 'file',
  172. header:{
  173. //"Authorization": userinfo.token
  174. },
  175. success: (res) => {
  176. let group = JSON.parse(res.data);
  177. that.mpImage=group.data;
  178. console.log(group)
  179. uni.showToast({
  180. title:that.$t('mend.shangccg'),
  181. icon:"success"
  182. })
  183. }
  184. });
  185. },
  186. getaddressxq(id){
  187. api('getaddressxq',{
  188. id: id
  189. },r=>{
  190. console.log('getaddressxq:',r);
  191. this.latitude=r.data.data.latitude;
  192. this.longitude=r.data.data.longitude;
  193. this.address=r.data.data.address;
  194. this.xingzhengqw=r.data.data.address;
  195. this.phone=r.data.data.phone;
  196. this.area=r.data.data.area;
  197. this.name=r.data.data.name;
  198. this.mpImage=r.data.data.annexes;
  199. this.jinzhishur=false;
  200. },failc=>{
  201. //console.log('getadvertis----',failc)
  202. })
  203. },
  204. updataAddr(){
  205. if(this.address.length<1){
  206. uni.showToast({
  207. title:this.$t('index.qsrxiangxidz'),
  208. icon:"none"
  209. })
  210. return;
  211. }
  212. if(this.name.length<1){
  213. uni.showToast({
  214. title:this.$t('index.qsrlianxiren'),
  215. icon:"none"
  216. })
  217. return;
  218. }
  219. if(this.phone.length<1){
  220. uni.showToast({
  221. title:this.$t('index.shoujihao'),
  222. icon:"none"
  223. })
  224. return;
  225. }
  226. this.postaddress();
  227. },
  228. deleteAddr(){
  229. if(this.id<0){
  230. console.log('未提交的新地址');
  231. }
  232. else{
  233. var that = this;
  234. uni.showModal({
  235. cancelText:that.$t('order.quxiao'),
  236. confirmText:that.$t('comp.queren'),
  237. title: that.$t('api.message'),
  238. content:that.$t('index.shanchuAddr'),
  239. success: function (res) {
  240. if (res.confirm) { //这里是点击了确定以后
  241. that.deleaddress();
  242. } else { //这里是点击了取消以后
  243. console.log('点击取消')
  244. }
  245. }
  246. })
  247. }
  248. },
  249. deleaddress(){
  250. api('deleaddress',{
  251. id:this.id
  252. },res=>{
  253. console.log('deleaddress:',res);
  254. uni.navigateBack();
  255. },failc=>{
  256. //console.log('getadvertis----',failc)
  257. })
  258. },
  259. postaddress(){
  260. var addr;
  261. if(this.id<0){
  262. addr={
  263. name:this.name,
  264. phone:this.phone,
  265. address: this.address,
  266. longitude:this.longitude,
  267. latitude: this.latitude,
  268. country:'',
  269. province:'',
  270. city:'',
  271. area:this.area,
  272. annexes:this.mpImage
  273. }
  274. }
  275. else{
  276. addr={
  277. id:this.id,
  278. name:this.name,
  279. phone:this.phone,
  280. address: this.address,
  281. longitude:this.longitude,
  282. latitude: this.latitude,
  283. country:'',
  284. province:'',
  285. city:'',
  286. area:this.area,
  287. annexes:this.mpImage
  288. }
  289. }
  290. console.log('addr:',addr);
  291. api('ADDaddress',addr,
  292. res=>{
  293. console.log('getGoodsDetail:',res);
  294. uni.navigateBack();
  295. },failc=>{
  296. //console.log('getadvertis----',failc)
  297. })
  298. },
  299. }
  300. }
  301. </script>
  302. <style>
  303. .contentV{
  304. width: 100%;
  305. position: relative;
  306. height: 94vh;
  307. }
  308. .linesp{
  309. width: 100%;
  310. height: 8rpx;
  311. background-color: aliceblue;
  312. }
  313. .topaddrCTV{
  314. margin-top: 60rpx;
  315. padding-bottom: 20rpx;
  316. width: 90%;
  317. margin-left: 5%;
  318. }
  319. .bottomline{
  320. border: solid lightgray;
  321. border-width: 0px 0px 2rpx 0px;
  322. }
  323. .areaT{
  324. overflow: hidden;
  325. text-overflow: ellipsis;
  326. display: -webkit-box;
  327. -webkit-line-clamp: 2;
  328. -webkit-box-orient: vertical;
  329. }
  330. .addressT{
  331. overflow: hidden;
  332. text-overflow: ellipsis;
  333. display: -webkit-box;
  334. -webkit-line-clamp: 2;
  335. -webkit-box-orient: vertical;
  336. }
  337. .slot-image {
  338. /* #ifndef APP-NVUE */
  339. display: block;
  340. /* #endif */
  341. margin-right: 10px;
  342. width: 30px;
  343. height: 30px;
  344. }
  345. .xialakuang{
  346. display: flex;
  347. flex-direction: row;
  348. align-items: center;
  349. justify-content:space-between;
  350. padding-left: 10rpx;
  351. width: 140rpx;
  352. height: 60rpx;
  353. margin-right: 20rpx;
  354. border-radius: 10rpx;
  355. border: 2rpx solid darkgray;
  356. }
  357. .inputctV{
  358. width: 90%;
  359. height: 120rpx;
  360. margin-left: 5%;
  361. margin-top: 30rpx;
  362. }
  363. .ctinrow{
  364. display: flex;
  365. flex-direction: row;
  366. align-items: center;
  367. justify-content: left;
  368. }
  369. .inputV{
  370. margin-top: 8rpx;
  371. width: 100%;
  372. height: 60rpx;
  373. font-size: 28rpx;
  374. border-radius: 8rpx;
  375. border: 2rpx solid darkgray;
  376. }
  377. .inputphone{
  378. margin-top: 8rpx;
  379. width: 100%;
  380. height: 60rpx;
  381. font-size: 28rpx;
  382. border-radius: 8rpx;
  383. border: 2rpx solid darkgray;
  384. }
  385. .savebt{
  386. text-align: center;
  387. font-size: 36rpx;
  388. width: 80%;
  389. height: 80rpx;
  390. line-height: 80rpx;
  391. color: white;
  392. background-color: green;
  393. border-radius: 10rpx;
  394. }
  395. .delbt{
  396. margin-top: 50rpx;
  397. text-align: center;
  398. font-size: 36rpx;
  399. width: 80%;
  400. height: 80rpx;
  401. line-height: 80rpx;
  402. color: white;
  403. background-color: darkgray;
  404. border-radius: 10rpx;
  405. }
  406. .imagV{
  407. width: 640rpx;
  408. height: 640rpx;
  409. background-color: antiquewhite;
  410. }
  411. .picker-view {
  412. width: 750rpx;
  413. height: 300rpx;
  414. margin-top: 10rpx;
  415. }
  416. .item {
  417. line-height: 100rpx;
  418. text-align: center;
  419. }
  420. </style>