customized.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. <template>
  2. <view class="cooperation">
  3. <u-toast ref="uToast" />
  4. <view class="formBgc">
  5. <view class="msg">
  6. 因政策原因
  7. <text v-for="(item,index) in configAll.disable_send_province" :key="index">
  8. {{item.name | areaName}}
  9. </text>不发货
  10. </view>
  11. <view class="form">
  12. <view class="formInput">
  13. <u-form :model="form" label-width="280">
  14. <u-form-item label="预定号码" >
  15. <u-input v-model="form.no" placeholder-style="font-size:26rpx;" :clearable="false" placeholder="请输入预定号码"/>
  16. </u-form-item>
  17. <u-form-item label="可接受最低价格" class="remark">
  18. <u-input v-model="form.price_min" placeholder-style="font-size:26rpx;" :clearable="false" placeholder="请输入最低价格"/>
  19. </u-form-item>
  20. <u-form-item label="可接受最高价格" class="remark">
  21. <u-input v-model="form.price_max" placeholder-style="font-size:26rpx;" :clearable="false" placeholder="请输入最高价格"/>
  22. </u-form-item>
  23. <u-form-item label="备注信息" class="remark">
  24. <u-input v-model="form.remark" placeholder-style="font-size:26rpx;" :clearable="false" placeholder="请输入备注信息"/>
  25. </u-form-item>
  26. <u-form-item label="姓名" >
  27. <u-input v-model="form.name" placeholder-style="font-size:26rpx;" :clearable="false" placeholder="请输入真实姓名"/>
  28. </u-form-item>
  29. <u-form-item label="联系电话" >
  30. <u-input v-model="form.phone" placeholder-style="font-size:26rpx;" :clearable="false" placeholder="请输入手机号"/>
  31. </u-form-item>
  32. <u-form-item label="城市" >
  33. <!-- <u-input v-model="" /> -->
  34. <view class="county" @tap="countyHide=!countyHide">
  35. {{countyName}}
  36. </view>
  37. <!-- 快手小程序 出现异常抖动更换 -->
  38. <!-- <u-select v-model="countyHide" :defaultValue='countyIndex' mode="mutil-column-auto" lchild-name="children" :list="selector" @confirm="confirm"></u-select> -->
  39. <w-picker
  40. :visible.sync="countyHide"
  41. mode="region"
  42. :value="countyIndex"
  43. default-type="value"
  44. :hide-area="false"
  45. @confirm="onConfirm($event,'region')"
  46. @cancel="onCancel"
  47. ref="region"
  48. ></w-picker>
  49. </u-form-item>
  50. <u-form-item label="详细地址" >
  51. <u-input v-model="form.address" placeholder-style="font-size:26rpx;" :clearable="false" placeholder="请输入街道/镇+村/小区+门牌号 "/>
  52. </u-form-item>
  53. </u-form>
  54. <view class="btn" @tap="order_no()">
  55. 立即预定
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </template>
  62. <script>
  63. import wPicker from "@/components/w-picker/w-picker.vue"
  64. export default {
  65. data() {
  66. return {
  67. countyName:'城市名称',
  68. countyHide:false,
  69. countyIndex:[1], //城市弹窗下标
  70. selector: [],
  71. form: {
  72. no:'',
  73. price_min:'',
  74. price_max:'',
  75. remark:'',
  76. name:'', //姓名
  77. phone:'', //手机号
  78. county:'', //城市ID,区县id
  79. address:'', //详细地址
  80. },
  81. };
  82. },
  83. components:{
  84. wPicker
  85. },
  86. onLoad() {
  87. this.area_tree()
  88. },
  89. filters:{
  90. areaName(val){
  91. return val.replace('省','').replace('特别行政区','').replace('壮族自治区','').replace('回族自治区','').replace('维吾尔自治区','').replace('自治区','')
  92. }
  93. },
  94. methods: {
  95. onConfirm(res){
  96. console.log(res)
  97. this.form.county=res.value[2]
  98. this.countyName=res.result
  99. this.countyIndex=res.value
  100. },
  101. onCancel(){
  102. },
  103. // 预定号码
  104. order_no(){
  105. if(this.form.no==''){
  106. this.$refs.uToast.show({
  107. title: '请输入预定手机号',
  108. type: 'error ',
  109. })
  110. return;
  111. }if(this.form.name==''){
  112. this.$refs.uToast.show({
  113. title: '请输入姓名',
  114. type: 'error ',
  115. })
  116. return;
  117. }
  118. if(!this.$check.checkName(this.form.name)){
  119. this.$refs.uToast.show({
  120. title: '请输入正确的格式',
  121. type: 'error ',
  122. })
  123. return;
  124. }
  125. if(this.form.phone==''){
  126. this.$refs.uToast.show({
  127. title: '请输入手机号',
  128. type: 'error ',
  129. })
  130. return;
  131. }
  132. if(!this.$check.checkMobile(this.form.phone)){
  133. this.$refs.uToast.show({
  134. title: '请输入正确手机号的格式',
  135. type: 'error ',
  136. })
  137. return;
  138. }
  139. if(this.form.address==''){
  140. this.$refs.uToast.show({
  141. title: '请输入地址',
  142. type: 'error ',
  143. })
  144. return;
  145. }
  146. this.$http.order_no(this.form)
  147. .then(res=>{
  148. console.log(res)
  149. if(res.data.code==1){
  150. this.$refs.uToast.show({
  151. title: '预定完成',
  152. type: 'success',
  153. })
  154. uni.reLaunch({
  155. url: '/pages/index/index',
  156. })
  157. }else{
  158. this.$refs.uToast.show({
  159. title: res.data.msg,
  160. type: 'error ',
  161. })
  162. }
  163. })
  164. },
  165. // 区域内容
  166. area_tree(){
  167. this.$http.area_tree().then(res => {
  168. if(res.data.code===1){
  169. this.selector=res.data.data
  170. console.log(this.selector)
  171. this.loca()
  172. }
  173. });
  174. },
  175. // 获取本地经纬度
  176. loca(){
  177. let this_=this;
  178. if(this_.mixin_type!='TOUTIAO' && this_.mixin_type!='H5'){
  179. ks.getSetting({
  180. success(res) {
  181. if (!res.authSetting['scope.userLocation']) {
  182. //提前向用户发起授权请求
  183. uni.getLocation({
  184. type: 'wgs84',
  185. success: function (res) {
  186. console.log('当前位置的经度:' + res.longitude);
  187. console.log('当前位置的纬度:' + res.latitude);
  188. this_.loAcquire(res.longitude,res.latitude)
  189. }
  190. });
  191. }
  192. },
  193. });
  194. }else if( this_.mixin_type=='H5'){
  195. this_.jsonp('https://apis.map.qq.com/ws/location/v1/ip',{
  196. key: "O7NBZ-PTTCG-OEPQF-I6MTS-YEKCJ-OCFVO",
  197. output: "jsonp"
  198. })
  199. .then(res=>{
  200. console.log(res.result.ad_info);
  201. let adInfo=res.result.ad_info
  202. this_.cityId(adInfo.province,adInfo.city,adInfo.district)
  203. })
  204. }else{
  205. uni.getLocation({
  206. type: 'wgs84',
  207. highAccuracyExpireTime:100,
  208. success: function (res) {
  209. console.log('当前位置的经度:' + res.longitude);
  210. console.log('当前位置的纬度:' + res.latitude);
  211. this_.loAcquire(res.longitude,res.latitude)
  212. }
  213. });
  214. }
  215. },
  216. // 根据经纬度查询城市
  217. loAcquire(longitude,latitude){
  218. let this_=this;
  219. this.myAmapFun.reverseGeocoder({
  220. location: {
  221. latitude: latitude,
  222. longitude: longitude
  223. },
  224. success: function(res) {
  225. console.log("解析地址成功");
  226. console.log(res);
  227. // 根据名称筛选id
  228. this_.cityId(res.result.address_component.province,res.result.address_component.city,res.result.address_component.district)
  229. },
  230. fail: function(res) {
  231. uni.showToast({
  232. title: '定位失败',
  233. duration: 2000,
  234. icon: "none"
  235. })
  236. console.log(res);
  237. },
  238. complete: function(res) {
  239. console.log(res);
  240. }
  241. })
  242. },
  243. // 城市选择id锁定
  244. confirm(e){
  245. console.log(e)
  246. this.form.county=e[2].value
  247. this.countyName=e[0].label+e[1].label+e[2].label
  248. },
  249. // 根据名称筛选id
  250. cityId(province,city,district){
  251. this.selector.forEach((val,i)=>{
  252. if(val.label.slice(0,2)==province.slice(0,2)||val.label==province){
  253. console.log(val.label)
  254. console.log(val.value)
  255. val.children.forEach((item,l)=>{
  256. if(item.label.slice(0,2)==city.slice(0,2)||item.label==city){
  257. console.log(item.label)
  258. console.log(item.value)
  259. item.children.forEach((con,y)=>{
  260. if(con.label.slice(0,2)==district.slice(0,2)||con.label==district){
  261. console.log(con.label)
  262. console.log(con.value)
  263. this.countyIndex=[i,l,y]
  264. this.countyName=val.label+item.label+con.label
  265. this.form.county=con.value
  266. }
  267. })
  268. }
  269. })
  270. }
  271. })
  272. },
  273. }
  274. };
  275. </script>
  276. <style lang="scss">
  277. .cooperation{
  278. width: 100%;
  279. .formBgc{
  280. // border-top: 1rpx solid #fff;
  281. width: 100%;
  282. height: 725rpx;
  283. background: linear-gradient(rgb(213, 46, 76), #fff);
  284. padding-top: 60rpx;
  285. .msg{
  286. font-size: 24rpx;
  287. color: #fff;
  288. text-align: center;
  289. margin-bottom: 30rpx;
  290. }
  291. .form {
  292. width: 703rpx;
  293. box-sizing: border-box;
  294. padding: 30rpx;
  295. position: relative;
  296. margin: 20rpx auto 10rpx;
  297. background-color: #fff;
  298. border-radius: 20rpx;
  299. .btn{
  300. width: 569rpx;
  301. height: 77rpx;
  302. line-height: 77rpx;
  303. background: #D52E4C;
  304. border-radius: 39rpx;
  305. margin: 20rpx auto;
  306. text-align: center;
  307. color: #fff;
  308. font-size: 32rpx;
  309. }
  310. .orderTit{
  311. text{
  312. margin-left: 30rpx;
  313. color: dimgray;
  314. }
  315. }
  316. .formInput{
  317. .u-form-item{
  318. /deep/ .u-form-item--left__content__label{
  319. position: relative;
  320. padding-left: 30rpx;
  321. }
  322. /deep/.u-form-item--left__content__label::after{
  323. content: '*';
  324. position: absolute;
  325. left: 18rpx;
  326. top: 0;
  327. color: red;
  328. }
  329. }
  330. .remark{
  331. /deep/.u-form-item--left__content__label::after{
  332. display: none;
  333. }
  334. }
  335. }
  336. }
  337. }
  338. }
  339. </style>