多租户商城-商户小程序端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

380 lines
8.2 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <view class="container flex-center flex-column">
  3. <view class="addressBack-box">
  4. <view class="consignee-box bor-line-F7F7F7">
  5. <input v-model="username" maxlength="20" class="fs28" placeholder-class="consignee" :placeholder="$t('common.name')" />
  6. </view>
  7. <view class="iphoneNum-box bor-line-F7F7F7">
  8. <input type="number" v-model="phone" maxlength="11" class="fs28" placeholder-class="iphoneNum" :placeholder="$t('common.mobilephone')" />
  9. </view>
  10. <view class="consignee-box bor-line-F7F7F7">
  11. <input v-model="bankName" maxlength="20" class="fs28" placeholder-class="consignee" :placeholder="$t('common.bankname')" />
  12. </view>
  13. <view class="cardnum">
  14. <input type="number" class="fs28" v-model="cardNum" maxlength="20" placeholder-class="detailAddress" :placeholder="$t('common.cardnum')" />
  15. </view>
  16. </view>
  17. <view class="deleteBankcard-box" v-if="type == 2">
  18. <label class="font-color-C5AA7B" @click="delBankcard">{{$t('common.delete')}}</label>
  19. </view>
  20. <view class="saveAddress-box">
  21. <view class="saveAddress" v-if="type == 1" @click="saveBankcardClick">{{$t('common.add')}}</view>
  22. <view class="saveAddress" v-else @click="saveBankcardClick">{{$t('common.save')}}</view>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. const NET = require('../../utils/request')
  28. const API = require('../../config/api')
  29. export default {
  30. data() {
  31. return {
  32. show: false,
  33. type: 1, // 1.添加银行卡 2.编辑银行卡
  34. cardNum: '',
  35. bankCode: '',
  36. bankName: '',
  37. bankTagList: [],
  38. username: '',
  39. phone: '',
  40. id: '',
  41. withdraw: '',
  42. choosedValueList: [0]
  43. }
  44. },
  45. onLoad(options) {
  46. if (options.type) {
  47. this.type = options.type
  48. }
  49. if (options.withdraw) {
  50. this.withdraw = options.withdraw
  51. }
  52. this.initBankList()
  53. if (this.type == 2) {
  54. this.bankcardId = uni.getStorageSync('bankcardId')
  55. this.renderBankcard(this.bankcardId)
  56. uni.removeStorageSync('bankcardId')
  57. }
  58. },
  59. onShow() {
  60. },
  61. methods: {
  62. renderBankcard(bankcardId) {
  63. const _ = this
  64. NET.request(API.GetByIdBankcard ,{bankId:bankcardId},"GET").then(res => {
  65. const bankCard = res.data
  66. _.id = bankcardId
  67. _.username = bankCard.name
  68. _.phone = bankCard.phone
  69. _.bankName = bankCard.bankName
  70. _.bankCode = bankCard.bankCode
  71. _.cardNum = bankCard.bankCard
  72. _.bankTagList.forEach((item, index) => {
  73. if (_.bankCode == item.value) {
  74. _.choosedValueList = [index]
  75. return
  76. }
  77. })
  78. }).catch(res => {
  79. })
  80. },
  81. initBankList() {
  82. const _ = this
  83. NET.request(API.QueryBankList).then(res => {
  84. _.bankTagList = res.data.map((item) => {
  85. return {
  86. 'value': item.bankCode,
  87. 'label': item.bankName
  88. }
  89. })
  90. }).catch(res => {
  91. })
  92. },
  93. //新增或更新银行卡
  94. saveBankcardClick() {
  95. const _ = this
  96. this.bankTagList.forEach((item, index) => {
  97. if (item.label == _.bankName) {
  98. _.bankCode = item.value
  99. }
  100. })
  101. let phoneCodeVerification = /^[1][3-9][0-9]{9}$/;
  102. const method = this.type == 1 ? 'POST' : 'PUT';
  103. if (this.username == '') {
  104. uni.showToast({
  105. title: '请输入姓名!',
  106. duration: 2000,
  107. icon: 'none'
  108. });
  109. } else if (this.phone == '') {
  110. uni.showToast({
  111. title: '请输入手机号!',
  112. duration: 2000,
  113. icon: 'none'
  114. });
  115. } else if (!phoneCodeVerification.test(this.phone)) {
  116. uni.showToast({
  117. title: '请输入正确的手机号!',
  118. duration: 2000,
  119. icon: 'none'
  120. });
  121. } else if (this.bankName == '') {
  122. uni.showToast({
  123. title: '请填写银行名称!',
  124. duration: 2000,
  125. icon: 'none'
  126. });
  127. }else if (this.cardNum == '') {
  128. uni.showToast({
  129. title: '请输入卡号!',
  130. duration: 2000,
  131. icon: 'none'
  132. });
  133. }else if (this.cardNum.length != 16 && this.cardNum.length != 19 ) {
  134. uni.showToast({
  135. title: '请输入正确的卡号!',
  136. duration: 2000,
  137. icon: 'none'
  138. });
  139. }else {
  140. if(this.type == 1){
  141. NET.request(API.SaveBankcard, {
  142. name: this.username,
  143. phone: this.phone,
  144. bankName: this.bankName,
  145. bankCard: this.cardNum
  146. }, 'POST').then(res => {
  147. if (res.code === "200") {
  148. uni.showToast({
  149. title: '添加成功',
  150. duration: 2000,
  151. icon: 'none'
  152. });
  153. if (this.withdraw == 1) {
  154. setTimeout(function(){
  155. uni.navigateTo({
  156. url: 'withdraw'
  157. })
  158. },2000)
  159. } else {
  160. setTimeout(function(){
  161. uni.navigateTo({
  162. url: 'bankcard'
  163. })
  164. },2000)
  165. }
  166. } else {
  167. uni.showToast({
  168. title: res.data.message,
  169. duration: 2000,
  170. icon: 'none'
  171. });
  172. }
  173. }).catch(res => {
  174. uni.showToast({
  175. title: res.data.message,
  176. duration: 2000,
  177. icon: 'none'
  178. });
  179. })
  180. }else{
  181. NET.request(API.UpdateBankcard, {
  182. bankId:this.id,
  183. name: this.username,
  184. phone: this.phone,
  185. bankName: this.bankName,
  186. bankCard: this.cardNum
  187. }, 'POST').then(res => {
  188. if (res.code === "200") {
  189. uni.navigateTo({
  190. url: 'bankcard'
  191. })
  192. } else {
  193. uni.showToast({
  194. title: res.msg,
  195. duration: 2000,
  196. icon: 'none'
  197. });
  198. }
  199. }).catch(res => {
  200. uni.showToast({
  201. title: '操作失败',
  202. duration: 2000,
  203. icon: 'none'
  204. });
  205. })
  206. }
  207. }
  208. },
  209. //删除银行卡
  210. delBankcard() {
  211. let _this = this;
  212. uni.showModal({
  213. title: _this.$t('common.notice_dialog_title'),
  214. content: '确认删除该银行卡?',
  215. confirmText: '确定',
  216. cancelText: '取消',
  217. success: (res) => {
  218. if (res.confirm) {
  219. this.subm()
  220. } else if (res.cancel) {
  221. }
  222. }
  223. })
  224. },
  225. subm() {
  226. NET.request(API.DelMemberBankcard, {
  227. bankId: this.bankcardId
  228. }, 'POST').then(res => {
  229. uni.navigateTo({
  230. url: 'bankcard'
  231. })
  232. }).catch(res => {
  233. })
  234. }
  235. }
  236. }
  237. </script>
  238. <style lang="scss">
  239. page {
  240. background-color: #F7F7F7;
  241. }
  242. .container {
  243. .addressBack-box {
  244. background-color: #FFFFFF;
  245. padding: 30upx 30upx;
  246. .consignee-box {
  247. padding-bottom: 36upx;
  248. width: 690upx;
  249. margin-top: 20upx;
  250. .consignee {
  251. color: #999999;
  252. font-size: 28upx;
  253. }
  254. }
  255. .iphoneNum-box {
  256. padding-bottom: 36upx;
  257. width: 690upx;
  258. margin-top: 36upx;
  259. .iphoneNum {
  260. color: #999999;
  261. font-size: 28upx;
  262. }
  263. }
  264. .location-box {
  265. padding-bottom: 36upx;
  266. width: 690upx;
  267. margin-top: 36upx;
  268. .location {
  269. color: #999999;
  270. font-size: 28upx;
  271. }
  272. }
  273. .bankTag-box {
  274. margin-top: 19px;
  275. padding-bottom: 19px;
  276. .addressTag {
  277. color: #999999
  278. }
  279. }
  280. .cardnum {
  281. margin-top: 19px;
  282. }
  283. .detailAddress-box {
  284. padding-bottom: 36upx;
  285. width: 690upx;
  286. margin-top: 36upx;
  287. .detailAddress {
  288. color: #999999;
  289. font-size: 28upx;
  290. }
  291. }
  292. }
  293. .addressTagBack-box {
  294. background-color: #FFFFFF;
  295. padding: 30upx 30upx;
  296. margin-top: 20upx;
  297. .addressTag-box {
  298. padding-bottom: 36upx;
  299. width: 690upx;
  300. .addressTag {
  301. color: #999999;
  302. font-size: 28upx;
  303. }
  304. }
  305. .defaultState-box {
  306. padding-bottom: 10upx;
  307. width: 690upx;
  308. margin-top: 36upx;
  309. .defaultState {
  310. color: #999999;
  311. font-size: 28upx;
  312. }
  313. }
  314. }
  315. .arrow {
  316. width: 24upx;
  317. height: 24upx;
  318. }
  319. .saveAddress-box {
  320. position: fixed;
  321. bottom: 50upx;
  322. left: 30upx;
  323. .saveAddress {
  324. width: 690rpx;
  325. height: 98rpx;
  326. color: #ffffff;
  327. text-align: center;
  328. line-height: 98rpx;
  329. background: #252744;
  330. border-radius: 50rpx;
  331. }
  332. }
  333. }
  334. .deleteBankcard-box {
  335. background-color: #FFFFFF;
  336. padding: 30upx 30upx;
  337. margin-top: 20upx;
  338. text-align: center;
  339. }
  340. .content {
  341. font-size: 35rpx;
  342. width: 500rpx;
  343. .btn {
  344. margin-bottom: 20rpx;
  345. width: 200rpx;
  346. background-image: linear-gradient(135deg, #FFA100 10%, #FF7911 100%);
  347. }
  348. }
  349. </style>