金诚优选前端代码
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.

369 lines
9.6 KiB

  1. <template>
  2. <view id="open_vip">
  3. <view class="recruit">
  4. <view class="banner-img">
  5. <image mode="widthFix" src="https://cdn.ibrand.cc/00434kkk.png"></image>
  6. </view>
  7. <view class="detail-box">
  8. <view class="item">
  9. <view class="title">
  10. <span class="left-dot"></span>
  11. 选择商品即可开通会员
  12. <span class="right-dot"></span>
  13. </view>
  14. <view class="bg-li" :data-id="item.id" @tap="jumpDetail" v-for="(item, index) in schemesList" :key="index" >
  15. <view class="info">
  16. <view class="left-box">
  17. <image :src="item.img"></image>
  18. </view>
  19. <view class="right-box">
  20. <view class="name">{{item.name}}</view>
  21. <view class="money-buy">
  22. <view class="money"> {{item.sell_price}}</view>
  23. <view class="active-btn" v-if="activeIndex == index">
  24. 已选择
  25. </view>
  26. <view class="buy-btn" v-else @tap.stop="select" :data-item="item" :data-index="index">
  27. 选择商品
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="triangle" v-if="activeIndex == index">
  33. <span class="iconfont icon-Group96"></span>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. <view class="vip-box" v-if="privilegeList.length">
  40. <view class="title">
  41. 米尔优选会员
  42. </view>
  43. <view class="list-content">
  44. <view class="li-item" v-for="(item, index) in privilegeList" :key="index" >
  45. <image mode="widthFix" :src="item.img"></image>
  46. </view>
  47. </view>
  48. </view>
  49. <!--按钮-->
  50. <view class="open-btn" @tap="openVip">
  51. 立即开通
  52. </view>
  53. </view>
  54. </template>
  55. <script>
  56. import {pageLogin, getUrl,config} from '@/common/js/utils.js';
  57. export default {
  58. data() {
  59. return {
  60. schemesList: '',
  61. //vip 的礼包充值列表
  62. select_schemesList: '',
  63. //选中的礼品
  64. activeIndex: -1,
  65. info: '',
  66. detail: '',
  67. goods_id: '',
  68. privilegeList: ''
  69. };
  70. },
  71. onShow() {
  72. var token = this.$cookieStorage.get('user_token');
  73. var agent_code = this.$cookieStorage.get('agent_code');
  74. this.getSchemesList();
  75. this.getPrivilegeList();
  76. /*if(token){
  77. this.getUserInfo();
  78. }*/
  79. },
  80. onLoad(e) {
  81. if (e.goods_id) {
  82. this.setData({
  83. goods_id: e.goods_id
  84. });
  85. }
  86. },
  87. components: {},
  88. props: {},
  89. methods: {
  90. //获取vip的充值列表
  91. getSchemesList() {
  92. var token = this.$cookieStorage.get('user_token');
  93. wx.showLoading({
  94. title: "加载中",
  95. mask: true
  96. });
  97. this.$http.get({
  98. api: 'api/vip/goods/list',
  99. header: {
  100. Authorization: token
  101. }
  102. }).then(res => {
  103. if (res.statusCode == 200) {
  104. res = res.data;
  105. if (res.status) {
  106. this.setData({
  107. schemesList: res.data
  108. });
  109. } else {
  110. wx.showModal({
  111. content: res.message || '请求失败',
  112. showCancel: false
  113. });
  114. }
  115. wx.hideLoading();
  116. } else {
  117. wx.hideLoading();
  118. wx.showModal({
  119. content: '请求失败',
  120. showCancel: false
  121. });
  122. }
  123. }).catch(rej => {
  124. wx.hideLoading();
  125. wx.showModal({
  126. content: '请求失败',
  127. showCancel: false
  128. });
  129. });
  130. },
  131. //获取vip的充值列表
  132. getPrivilegeList() {
  133. wx.showLoading({
  134. title: "加载中",
  135. mask: true
  136. });
  137. this.$http.get({
  138. api: 'api/member/privilege/list'
  139. }).then(res => {
  140. if (res.statusCode == 200) {
  141. res = res.data;
  142. if (res.status) {
  143. this.setData({
  144. privilegeList: res.data
  145. });
  146. } else {
  147. wx.showModal({
  148. content: res.message || '请求失败',
  149. showCancel: false
  150. });
  151. }
  152. wx.hideLoading();
  153. } else {
  154. wx.hideLoading();
  155. wx.showModal({
  156. content: '请求失败',
  157. showCancel: false
  158. });
  159. }
  160. }).catch(rej => {
  161. wx.hideLoading();
  162. wx.showModal({
  163. content: '请求失败',
  164. showCancel: false
  165. });
  166. });
  167. },
  168. //选择商品
  169. select(e) {
  170. let item = e.currentTarget.dataset.item;
  171. let index = e.currentTarget.dataset.index;
  172. // this.setData({
  173. // isSelected: true,
  174. // select_schemesList: item,
  175. // activeIndex: index
  176. // });
  177. this.isSelected=true;
  178. this.select_schemesList=item;
  179. this.activeIndex=index;
  180. },
  181. //跳到详情页
  182. jumpDetail(e) {
  183. var id = e.currentTarget.dataset.id;
  184. wx.navigateTo({
  185. url: '/pages/store/detail/detail?id=' + id
  186. });
  187. },
  188. //点击开通vip会员
  189. openVip() {
  190. var token = this.$cookieStorage.get('user_token');
  191. if (!token) {
  192. wx.navigateTo({
  193. url: '/pages/user/register/register'
  194. });
  195. return;
  196. }
  197. if (this.select_schemesList) {
  198. var data = {
  199. id: this.select_schemesList.meta.product_id,
  200. name: this.select_schemesList.name,
  201. qty: 1,
  202. store_count: this.select_schemesList.meta.store_count,
  203. price: this.select_schemesList.meta.price,
  204. market_price: this.select_schemesList.meta.market_price,
  205. product_id: this.select_schemesList.meta.product_id,
  206. attributes: {
  207. img: this.select_schemesList.meta.img || this.select_schemesList.img,
  208. size: this.select_schemesList.meta.size || '',
  209. color: this.select_schemesList.meta.color || '',
  210. com_id: this.select_schemesList.id,
  211. sku: this.select_schemesList.meta.sku || ''
  212. }
  213. };
  214. this.checkoutImmdeOrder(data);
  215. } else {
  216. wx.showModal({
  217. content: '请先选择会员商品礼包',
  218. showCancel: false
  219. });
  220. }
  221. },
  222. //请求立马购买接口
  223. checkoutImmdeOrder(data) {
  224. wx.showLoading({
  225. title: "加载中",
  226. mask: true
  227. });
  228. var token = this.$cookieStorage.get('user_token');
  229. this.$http.post({
  230. api: 'api/shopping/order/checkout?product_id=' + data.id,
  231. header: {
  232. Authorization: token
  233. },
  234. data: data
  235. }).then(res => {
  236. if (res.statusCode == 200) {
  237. res = res.data;
  238. if (res.status) {
  239. this.$cookieStorage.set('local_order', res.data);
  240. wx.hideLoading();
  241. wx.navigateTo({
  242. url: '/pages/store/order/order'
  243. });
  244. } else {
  245. if (res.data && res.data.server_busy) {
  246. this.setData({
  247. show_ten: true
  248. });
  249. } else if (res.message == 'User unbind mobile') {
  250. wx.showModal({
  251. content: '请先绑定手机号',
  252. showCancel: false,
  253. success: res => {
  254. if (res.confirm || !res.cancel && !res.confirm) {
  255. wx.navigateTo({
  256. url: '/pages/user/phone/phone?url=' + getUrl()
  257. });
  258. }
  259. }
  260. });
  261. } else {
  262. wx.showModal({
  263. content: res.message || '请求失败',
  264. showCancel: false
  265. });
  266. }
  267. wx.hideLoading();
  268. }
  269. }
  270. });
  271. },
  272. //请求推客会员的
  273. getInfo(agent_code) {
  274. wx.showLoading({
  275. title: '更新中',
  276. mask: true
  277. });
  278. this.$http.get({
  279. api: 'api/user/info/' + agent_code
  280. }).then(res => {
  281. if (res.statusCode == 200) {
  282. res = res.data;
  283. if (res.status) {
  284. this.setData({
  285. info: res.data
  286. });
  287. } else {
  288. wx.showModal({
  289. content: res.message || '请求失败',
  290. showCancel: false
  291. });
  292. }
  293. wx.hideLoading();
  294. } else {
  295. wx.showModal({
  296. content: '请求失败',
  297. showCancel: false
  298. });
  299. wx.hideLoading();
  300. }
  301. });
  302. },
  303. getUserInfo() {
  304. this.$http.get({
  305. api: 'api/me',
  306. header: {
  307. Authorization: this.$cookieStorage.get('user_token')
  308. }
  309. }).then(res => {
  310. if (res.data.status) {
  311. this.setData({
  312. detail: res.data.data
  313. });
  314. }
  315. });
  316. },
  317. setData: function (obj) {
  318. let that = this;
  319. let keys = [];
  320. let val, data;
  321. Object.keys(obj).forEach(function (key) {
  322. keys = key.split('.');
  323. val = obj[key];
  324. data = that.$data;
  325. keys.forEach(function (key2, index) {
  326. if (index + 1 == keys.length) {
  327. that.$set(data, key2, val);
  328. } else {
  329. if (!data[key2]) {
  330. that.$set(data, key2, {});
  331. }
  332. }
  333. data = data[key2];
  334. });
  335. });
  336. }
  337. },
  338. computed: {},
  339. watch: {}
  340. };
  341. </script>
  342. <style rel="stylesheet/less" lang="less">
  343. @import "openVip";
  344. </style>